我有幾個.gz文件,我想逐個解壓縮它們。 我已經寫了一個簡單的代碼在C#中使用GzipStream,但失敗了。我想知道一個正確和有用的方法來實現我想要的。非常感謝。使用GZipStream解壓縮.gz文件
private string Extrgz(string infile)
{
string dir = Path.GetDirectoryName(infile);
string decompressionFileName = dir + Path.GetFileNameWithoutExtension(infile) + "_decompression.bin";
using (GZipStream instream = new GZipStream(File.OpenRead(infile), CompressionMode.Compress))// ArgumentException...
{
using (FileStream outputStream = new FileStream(decompressionFileName, FileMode.Append, FileAccess.Write))
{
int bufferSize = 8192, bytesRead = 0;
byte[] buffer = new byte[bufferSize];
while ((bytesRead = instream.Read(buffer, 0, bufferSize)) > 0)
{
outputStream.Write(buffer, 0, bytesRead);
}
}
}
return decompressionFileName;
}
什麼異常/錯誤? –
@ Dan-o參數「流」錯誤 –