大家好,我收到了这个例外:
The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.
我所做的就是将文件解压缩为 GZip,然后将其传递到流中,然后将其传递到文件中。
using (FileStream fInStream = new FileStream(@"C:\Users\UNI\Desktop\FrostbyteDBUpdateProgram\FrostbyteDBUpdateProgram\bin\Debug\" + fileName, FileMode.Open, FileAccess.Read))
{
using (GZipStream gZip = new GZipStream(fInStream, CompressionMode.Decompress))
{
using (FileStream fOutStream = new FileStream(@"C:\Users\UNI\Desktop\FrostbyteDBUpdateProgram\FrostbyteDBUpdateProgram\bin\Debug\test1.docx", FileMode.Create, FileAccess.Write))
{
byte[] tempBytes = new byte[4096];
int i;
while ((i = gZip.Read(tempBytes, 0, tempBytes.Length)) != 0)
{
fOutStream.Write(tempBytes, 0, i);
}
}
gZip.Close();
}
fInStream.Close();
}