我想解压一个exe文件,该文件包含一些文件和文件夹。当我尝试使用WinRAR提取文件时,它可以被提取出来,但是当我尝试使用一些示例来提取exe文件时,我会收到以下错误信息:
“GZip头中的魔数不正确,请确保您正在传递GZip流。”
我已经尝试了一些示例并进行了大量搜索,但没有找到答案,我还使用了一些库。
我尝试了以下代码,但仍然出现相同的错误:
“GZip头中的魔数不正确,请确保您正在传递GZip流。”
我已经尝试了一些示例并进行了大量搜索,但没有找到答案,我还使用了一些库。
我尝试了以下代码,但仍然出现相同的错误:
public static void Decompress(FileInfo fi)
{
// Get the stream of the source file.
using (FileStream inFile = fi.OpenRead())
{
// Get original file extension, for example
// "doc" from report.doc.gz.
string curFile = fi.FullName;
string origName = curFile.Remove(curFile.Length -
fi.Extension.Length);
//Create the decompressed file.
using (FileStream outFile = File.Create(origName))
{
using (GZipStream Decompress = new GZipStream(inFile,
CompressionMode.Decompress))
{
// Copy the decompression stream
// into the output file.
Decompress.CopyTo(outFile);
Console.WriteLine("Decompressed: {0}", fi.Name);
}
}
}
}