[
  {
    "Id": "212909",
    "ThreadId": "62726",
    "Html": "<p>I am currently creating my zip file with a bunch of different xml files from memory stream as follows:</p>\r\n<p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>            <span style=\"color:Blue\">using</span> (Ionic.Zip.ZipFile zip = <span style=\"color:Blue\">new</span> Ionic.Zip.ZipFile(saveFileDialog1.FileName.ToString()))\r\n            {\r\n                zip.AddFileFromString(<span style=\"color:#A31515\">&quot;File1.xml&quot;</span>, <span style=\"color:#A31515\">&quot;&quot;</span>, xmlSerializedFile1);\r\n                zip.AddFileFromString(<span style=\"color:#A31515\">&quot;File2.xml&quot;</span>, <span style=\"color:#A31515\">&quot;&quot;</span>, xmlSerializedFile2);\r\n                zip.AddFileFromString(<span style=\"color:#A31515\">&quot;File3.xml&quot;</span>, <span style=\"color:#A31515\">&quot;&quot;</span>, xmlSerializedFile3);\r\n                zip.Save();\r\n            }\r\n<br>The above is done in a button click event. Now on the first click, the files doesnt exist within the zip file, so it works just fine. Now when I click the button again to do the save, i get an ArgumentException - The entry 'File1' already exists in the zip archive.<br><br>What is the best and easiest way to just overwrite the existing Files? I dont care to loose the data in the existing files (File1, File2, File3) within the zip, I just want to overwrite with the new Files. Do I have to test for an existing file? Or is there a simpler way to just brute force overwrite?<br></pre>\r\n</div>\r\n</p>",
    "PostedDate": "2009-07-17T00:54:31.023-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "212958",
    "ThreadId": "62726",
    "Html": "<p>If you are using v1.8 or later, you can call UpdateEntry() .&nbsp; It will add a new file if none exists, and it will replace the existing file if it does exist.</p>\r\n<p style=\"color:Red\">Also in v1.8, the ZipFile.AddFileFromString() method was renamed to AddEntry().</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-07-17T03:21:04.007-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213117",
    "ThreadId": "62726",
    "Html": "<p>I wonder if this is a bug. I am serializing a class into XML using the following serializer code:</p>\r\n<p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>        <span style=\"color:Blue\">public</span> <span style=\"color:Blue\">static</span> <span style=\"color:Blue\">string</span> SerializeObject&lt;T&gt;(Encoding encoding, T obj)\r\n        {\r\n            <span style=\"color:Blue\">try</span>\r\n            {\r\n                MemoryStream memoryStream = <span style=\"color:Blue\">new</span> MemoryStream();\r\n\r\n                <span style=\"color:Blue\">using</span> (XmlTextWriter xmlTextWriter = <span style=\"color:Blue\">new</span> XmlTextWriter(memoryStream, encoding))\r\n                {\r\n                    XmlSerializer xmlSerializer = <span style=\"color:Blue\">new</span> XmlSerializer(<span style=\"color:Blue\">typeof</span>(T));\r\n                    xmlSerializer.Serialize(xmlTextWriter, obj);\r\n\r\n                    memoryStream = (MemoryStream)xmlTextWriter.BaseStream;\r\n                }\r\n\r\n                <span style=\"color:Blue\">return</span> ByteArrayToString(encoding, memoryStream.ToArray());\r\n            }\r\n            <span style=\"color:Blue\">catch</span>\r\n            {\r\n                <span style=\"color:Blue\">return</span> <span style=\"color:Blue\">string</span>.Empty;\r\n            }\r\n        }\r\n</pre>\r\n</div>\r\n</p>\r\n<p>I am currently using the 1.7 version of DotNetZip, and using the zip save code listed above (initial post), i am serializing the class and saving it as an xml file within the zip. I can extract the zip after its saved, and the xml file can be opened easily with IE and the data displayed.</p>\r\n<p>I then downloaded the latest version 1.8, and modified the zip code to zip.AddEntry (cause it was complaining that AddFileFromString is obsolete) and when i serialize the same class and save it, I cant seem to open the xml file in IE. When I edit the xml file, it looks like there is an extra leading '?' that is causing this.</p>\r\n<p>I tried saving some text via string into a text file, and then zipping it, but i dont have the same problem. I know the xmlserializing code works fine because i didnt have this problem with the 1.7 version.</p>\r\n<p>Could this be a bug in the 1.8 version?</p>",
    "PostedDate": "2009-07-17T10:22:56.797-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213148",
    "ThreadId": "62726",
    "Html": "<p>It could be.&nbsp; I'd have to take a look at it.</p>",
    "PostedDate": "2009-07-17T11:15:03.803-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213152",
    "ThreadId": "62726",
    "Html": "<p>One more thought - text encoding</p>\r\n<p>In v1.8, the AddEntry/UpdateEntry methods use System.Text.Encoding.Default.&nbsp; In the v1.7, the AddFileFromString()&nbsp;used UTF-8 to do the encoding.&nbsp;</p>\r\n<p>There are overloads of AddEntry/UpdateEntry &nbsp;that accept an encoding.&nbsp; If you pass UTF8 there, you should get the same results as you had in v1.7.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-07-17T11:23:05.183-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213285",
    "ThreadId": "62726",
    "Html": "<p>it was the encoding, i changed the serialization encoding to Encoding.Default. I wasnt paying attention to this since it wasnt in the 1.7 version.</p>\r\n<p>Thanks, and great job on DotNetZip..very useful.</p>",
    "PostedDate": "2009-07-17T20:13:12.44-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "213289",
    "ThreadId": "62726",
    "Html": "<p>glad you are finding it useful.</p>",
    "PostedDate": "2009-07-17T20:33:22.613-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]