When I am zipping folder which is having some files I am getting the following error.But the same folder able to zip in the second try..
ICSharpCode.SharpZipLib.Zip.ZipException: size was 0, but I expected 14194 at ICSharpCode.SharpZipLib.Zip.ZipOutputStream.CloseEntry() at ICSharpCode.SharpZipLib.Zip.ZipOutputStream.Finish() at ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream.Close() at System.IO.Stream.Dispose() at ICSharpCode.SharpZipLib.Zip.FastZip.CreateZip(Stream outputStream, String sourceDirectory, Boolean recurse, String fileFilter, String directoryFilter)
at ICSharpCode.SharpZipLib.Zip.FastZip.CreateZip(String zipFileName, String sourceDirectory, Boolean recurse, String fileFilter)
Please suggest me the reason for this. The piece of code that I am using as follows
public static void ZipFolder(string sourceFolder, string zipUrl){ FastZip fZip = null; try { if ( !Directory.Exists( Path.GetDirectoryName( zipUrl ))) { Directory.CreateDirectory( Path.GetDirectoryName( zipUrl ) ); } fZip = new FastZip(); fZip.CreateEmptyDirectories = true; fZip.CreateZip(zipUrl, sourceFolder, true, null); } catch (Exception ex) { Debug.WriteLine("Exception in ZipFolder():" + ex.ToString()); throw; }
}