我有一些代码可以下载gzip压缩文件并对其进行解压缩.问题是,我无法解压缩整个文件,它只读取前4096个字节,然后再读取大约500个字节. 
  
  
 
Byte[] buffer = new Byte[4096];
int count = 0;
FileStream fileInput = new FileStream("input.gzip",FileMode.Open,FileAccess.Read,FileShare.Read);
FileStream fileOutput = new FileStream("output.dat",FileMode.Create,FileAccess.Write,FileShare.None);
GZipStream gzipStream = new GZipStream(fileInput,CompressionMode.Decompress,true);
// Read from gzip steam
while ((count = gzipStream.Read(buffer,buffer.Length)) > 0)
{
    // Write to output file
    fileOutput.Write(buffer,count);
}
// Close the streams
... 
 我检查了下载的文件;它在压缩时为13MB,包含一个XML文件.我手动解压缩了XML文件,内容就在那里.但是,当我使用此代码执行此操作时,它只输出XML文件的最开头.
任何人都有任何想法为什么会发生这种情况?
解决方法
 编辑 
  
 
        尽量不要打开GZipStream:
GZipStream gzipStream = new GZipStream(fileInput,false);
要么
GZipStream gzipStream = new GZipStream(fileInput,CompressionMode.Decompress);