I have the following method in my code:
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;
}
}
This code generates a ZIP file with all the correct entries, but each file is listed as being 4 TB (both unpacked and packed) and creates the following error when I try to open it:
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
The code is practically taken from the samples, but I seem to be missing something. Does anyone have any pointers?