我是学生我正在尝试解压缩gz文件,但它提供了以下错误消息:
说明GZip标题中的幻数是不正确的,这里是代码,如果任何1可以让我知道我在做什么错误,我真的感到满意
FileInfo fileToDecompress = new FileInfo(dirpath);
{
Decompress(fileToDecompress);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
public static void Decompress(FileInfo fileToDecompress)
{
using (FileStream originalFileStream = fileToDecompress.OpenRead())
{
string currentFileName = fileToDecompress.FullName;
string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
using (FileStream decompressedFileStream = File.Create(newFileName))
{
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress,true))
{
decompressionStream.CopyTo(decompressedFileStream);
Console.WriteLine("Decompressed: {0}", fileToDecompress.Name);
}
}
}
}
#region ScriptResults declaration
/// <summary>
/// This enum provides a convenient shorthand within the scope of this class for setting the
/// result of the script.
///
/// This code was generated automatically.
/// </summary>
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
答案 0 :(得分:0)
这意味着它所说的。您认为gzip文件不是,并且不是以0x1f 0x8b
开头。