[
  {
    "Id": "1222980",
    "ThreadId": "539058",
    "Html": "DotNetZip v1.9.1.8, .NET4, Win8.1, Desktop App.<br />\n<br />\nI am adding around 10 files one at a time by calling the function below, saving the ZIP when every file is added. For some reason the larger (8MB or so) file gets corrupted when I unzip it with DotNetZip and 7zip. No errors are reported during the compression. Testing the ZIP in 7zip reports a CRC error. <br />\n<br />\nAntivirus software is just Windows Defender.<br />\nIf I use 7zip to create the same archive there is no corruption. <br />\nAll files are on local HDD's.<br />\n<pre><code>\n        public static bool AddFile(string sZIPFile, string sFileToAdd, string sNameInArchive, string sPassword = null)\n        {\n            try\n            {\n                // File exists?\n                if(File.Exists(sZIPFile))\n                {\n                    // Remove existing\n                    using (ZipFile zip = ZipFile.Read(sZIPFile))\n                    {\n                        if(String.IsNullOrEmpty(sPassword)==false) zip.Password = sPassword;\n                        //zip[sNameInArchive].FileName = null;\n                        zip.RemoveEntry(sNameInArchive);\n                        zip.Save();\n                    }   \n                }\n                else\n                {\n                    // Create new ZIP\n                    ZipFile zip = new ZipFile(sZIPFile);\n                    zip.Save();\n                }\n            }\n            catch(Exception)\n            {}\n            \n                \n            try\n            {\n                // Get just the filename\n                string sAddFileName = Path.GetFileName(sFileToAdd);\n            \n                // Add file to zip\n                using (ZipFile zip = ZipFile.Read(sZIPFile))\n                {\n\n                    \n                    // update\n                    if(String.IsNullOrEmpty(sPassword)==false) zip.Password = sPassword;\n                    \n                    zip.UpdateItem(sFileToAdd,&quot;&quot;);\n                    zip[sAddFileName].FileName = sNameInArchive;\n                    //zip[sAddFileName].Comment = \n                    \n\n                    // add a comment to the archive\n                    //zip.Comment = \n                    zip.Save();\n                }\n                \n\n            }\n            catch(Exception ex)\n            {\n                System.Diagnostics.Debug.WriteLine(&quot;ZipHelper AddFile Exception: &quot;+ex.Message);\n                return false;\n            }\n                \n            return true;\n        }       </code></pre>\n\nLoop code calling the AddFile function above<br />\n<pre><code>\n        string[] sFiles = Directory.GetFiles(sBase+sFolderName);\n\n        foreach(string sFile in sFiles)\n        {\n            bool bret = ZipHelper.AddFile(sZIP, sFile, Path.GetFileName(sFile), null);\n            if(bret==false) ErrMsg(&quot;AddZip Failed &quot;+sFile);\n        }</code></pre>\n\n",
    "PostedDate": "2014-03-14T19:47:05.867-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]