Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can plug a stream in between which counts, how many bytes GZipStream has read.</p> <pre><code> public class ProgressStream : Stream { public long BytesRead { get; set; } Stream _baseStream; public ProgressStream(Stream s) { _baseStream = s; } public override bool CanRead { get { return _baseStream.CanRead; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return false; } } public override void Flush() { _baseStream.Flush(); } public override long Length { get { throw new NotImplementedException(); } } public override long Position { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public override int Read(byte[] buffer, int offset, int count) { int rc = _baseStream.Read(buffer, offset, count); BytesRead += rc; return rc; } public override long Seek(long offset, SeekOrigin origin) { throw new NotImplementedException(); } public override void SetLength(long value) { throw new NotImplementedException(); } public override void Write(byte[] buffer, int offset, int count) { throw new NotImplementedException(); } } // usage FtpWebResponse response = ftpclientRequest.GetResponse() as FtpWebResponse; using (Stream ftpStream = response.GetResponseStream()) using (ProgressStream progressStream = new ProgressStream(ftpstream)) using (GZipStream unzipped = new GZipStream(progressStream, CompressionMode.Decompress)) using (StreamReader linereader = new StreamReader(unzipped)) { String l; while ((l = linereader.ReadLine()) != null) { progressStream.BytesRead(); // does contain the # of bytes read from FTP so far. } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload