1
我是學生,我試圖要解壓的文件,GZ,但它提供了以下錯誤信息:解壓加上.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
}
馬克,希望你做得很好。 引用我的查詢時,我試圖解壓縮爲壓縮文件(.gz),它顯示以下錯誤消息。 我不明白爲什麼會發生這種情況。 謝謝 Subiraj –