I read the .gz file from a small source (for example, an FTP server) and immediately process the received data. It looks something like this:
FtpWebResponse response = ftpclientRequest.GetResponse() as FtpWebResponse;
using (Stream ftpStream = response.GetResponseStream())
using (GZipStream unzipped = new GZipStream(ftpStream, CompressionMode.Decompress))
using (StreamReader linereader = new StreamReader(unzipped))
{
String l;
while ((l = linereader.ReadLine()) != null)
{
...
}
}
My problem shows an accurate progress bar. In advance, I can get the compressed size of the .gz file, but I did not understand how large the content will be uncompressed. Reading the file line by line, I know pretty well how many uncompressed bytes I read, but I don't know how this relates to the compressed file size.
So, is there a way to get from GZipStream how far the file pointer translates to a compressed file? I only need the current position, the size of the gz file, which I can extract before reading the file.
source
share