我使用下面的代码压缩文件,它可以正常工作,但是当我使用 WinRar 解压缩时,我得到的原始文件名没有扩展名,如果文件名是 myReport.xls
,那么在解压缩时我只能得到 myReport
,有什么线索吗?
using (var fs = new FileStream(fileName, FileMode.Open))
{
byte[] input = new byte[fs.Length];
fs.Read(input, 0, input.Length);
fs.Close();
using (var fsOutput = new FileStream(zipName, FileMode.Create, FileAccess.Write))
using(var zip = new GZipStream(fsOutput, CompressionMode.Compress))
{
zip.Write(input, 0, input.Length);
zip.Close();
fsOutput.Close();
}
}