我的代码中有以下方法:
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 文件,但每个文件都列为 4 TB(未打包和打包),并在我尝试打开它时创建以下错误:
Extracting to "C:\winnt\profiles\jbladt\LOCALS~1\Temp\"
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
代码实际上取自样本,但我似乎遗漏了一些东西。有没有人有任何指示?