我在我的代码中有以下的方法:
private bool GenerateZipFile(List<FileInfo> filesToArchive, DateTime archiveDate)
{
try
{
using (ZipOutputStream zipStream = new ZipOutputStream(File.Create(GetZipFileName(archiveDate))))
{
zipStream.SetLevel(9); // maximum compression.
byte[] buffer = new byte[4096];
foreach (FileInfo fi in filesToArchive)
{
string fileName = ZipEntry.CleanName(fi.Name);
ZipEntry entry = new ZipEntry(fileName);
entry.DateTime = fi.LastWriteTime;
zipStream.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(fi.FullName))
{
StreamUtils.Copy(fs, zipStream, buffer);
}
zipStream.CloseEntry();
}
zipStream.Finish();
zipStream.Close();
}
return true;
}
catch (Exception ex)
{
OutputMessage(ex.ToString());
return false;
}
}
这个代码生成了一个包含所有正确条目的ZIP文件,但每个文件都被列为4TB(未打包和已打包),当我试图打开它时会出现以下错误:
Extracting to "C:winntprofilesjbladtLOCALS~1Temp"
Use Path: no Overlay Files: yes
skipping: QPS_Inbound-20081113.txt: this file is not in the standard Zip 2.0 format
Please see www.winzip.com/zip20.htm for more information
error: no files were found - nothing to do
这个代码基本上是从示例中取出的,但似乎我少了什么东西。有没有人有什么提示?