When there is a file "in use", SharpZiplib (version 0.85.5.452) creates corrupt zipfiles.
Is this a known issue ?
I create zipfile with:
ZipFile z = ZipFile.Create(zipFileStoragePath + zipFileName);
z.BeginUpdate();
GetFilesToZip(fileSystemInfosToZip, z);
z.CommitUpdate();
z.Close();
private static void GetFilesToZip(FileSystemInfo[ fileSystemInfosToZip, ZipFile z)
{
if (fileSystemInfosToZip != null && z != null)
{
foreach (FileSystemInfo fi in fileSystemInfosToZip)
{
if (fi is DirectoryInfo)
{
DirectoryInfo di = (DirectoryInfo)fi;
z.AddDirectory(di.FullName);
GetFilesToZip(di.GetFileSystemInfos(), z); // recursive !
}
else
{
z.Add(fi.FullName);
}
}
}
When opening a random file (with Excel) , no errors are generated when zipping, but result is a corrupt zipfile.