Hi everyone!
I have the problem, that it may happen, that one of the files added to the ZIP container, gets invalid. I have for example a directory of *.tif files - lets say 500. Sporadically it may happen, that one of the 500 files added to the ZIP cannot be opened. It is not very often and the source file is fine. Creating the ZIP with all files again usually solves the problem. But that cannot be the solution.
How can I check each file after adding it to the zip file (before finishing the zip)? (Or the final zip file after creating it?)
Right now, this happens:
ArrayList ar = GenerateFileList(input);
FileStream stream;
byte[ buffer;
ZipOutputStream ZipStream = new ZipOutputStream(File.Create(output));
ZipStream.SetLevel(0);
ICSharpCode.SharpZipLib.Zip.ZipEntry ZipEntry;
foreach (string Fil in ar)
{
ZipEntry = new ICSharpCode.SharpZipLib.Zip.ZipEntry(Fil.Remove(0, TrimLength));
ZipStream.PutNextEntry(ZipEntry);
if (!Fil.EndsWith(@"/"))
{
stream = File.OpenRead(Fil);
buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
ZipStream.Write(buffer, 0, buffer.Length);
stream.Close();
}
}
ZipStream.Finish();
ZipStream.Close();
ZipStream.Dispose();