[
  {
    "Id": "240652",
    "ThreadId": "70644",
    "Html": "<p>Hi,</p>\r\n<p>I have Ionic.Zip&nbsp;1.8.4.24 and using it to create password protected&nbsp;zip file from text file, &nbsp;that are used as an input to IBM Mainframe.</p>\r\n<p>I run into problem that the file I produce&nbsp;diagrammatically&nbsp;is in the binary format.</p>\r\n<p>Even though PKZIP on&nbsp;Mainframe&nbsp;seems to be able to extract the file,</p>\r\n<p>the system into which the file is supposed to be inputed complains that the file is in Binary format.</p>\r\n<p>If I manually create a zip file &nbsp;from the same text file using WinZip, then MF system accepts it, specifying that it's format is text.</p>\r\n<p>Can you help?</p>\r\n<p>snippets&nbsp;of code to do actual ziping:</p>\r\n<p>using Ionic.Zip;</p>\r\n<p>...</p>\r\n<p>&nbsp;</p>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; try</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; {</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> using (ZipFile zip = new ZipFile())</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> {</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> zip.Password = &quot;!P@WD#&quot;;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> zip.AddFile(FileName, &quot;&quot;);</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> zip.Save(ZipFileName);</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> }</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\"><span style=\"white-space:pre\"> </span> }</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; catch (System.Exception ex1)</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; {</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; System.Console.Error.WriteLine(&quot;exception: &quot; + ex1);</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:23px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; }</div>\r\n<p>\r\n<p>&nbsp;&nbsp; try</p>\r\n<p>&nbsp;&nbsp; {</p>\r\n<p><span style=\"white-space:pre\"> </span> using (ZipFile zip = new ZipFile())</p>\r\n<p><span style=\"white-space:pre\"> </span> {</p>\r\n<p><span style=\"white-space:pre\"> </span> zip.Password = &quot;somepassword&quot;;</p>\r\n<p><span style=\"white-space:pre\"> </span> zip.AddFile(FileName, &quot;&quot;);</p>\r\n<p><span style=\"white-space:pre\"> </span> zip.Save(ZipFileName);</p>\r\n<p><span style=\"white-space:pre\"> </span> }</p>\r\n<p><span style=\"white-space:pre\"> </span> }</p>\r\n<p>&nbsp;&nbsp; catch (System.Exception ex1)</p>\r\n<p>&nbsp;&nbsp; {</p>\r\n<p>&nbsp;&nbsp; &nbsp; System.Console.Error.WriteLine(&quot;exception: &quot; + ex1);</p>\r\n<p>&nbsp;&nbsp; }</p>\r\n<div></div>\r\n</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-30T14:51:43.257-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240654",
    "ThreadId": "70644",
    "Html": "<p>Yes, try setting the IsText property on the ZipEntry:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>  <span style=\"color:Blue\">try</span>\r\n  {\r\n    <span style=\"color:Blue\">using</span> (ZipFile zip = <span style=\"color:Blue\">new</span> ZipFile())\r\n    {\r\n      zip.Password = <span style=\"color:#A31515\">&quot;somepassword&quot;</span>;\r\n      <span style=\"color:Blue\">var</span> e= zip.AddFile(FileName, <span style=\"color:#A31515\">&quot;&quot;</span>);\r\n      e.IsText = <span style=\"color:Blue\">true</span>;\r\n      zip.Save(ZipFileName);\r\n    }\r\n  }\r\n  <span style=\"color:Blue\">catch</span> (System.Exception ex1)\r\n  {\r\n    System.Console.Error.WriteLine(<span style=\"color:#A31515\">&quot;exception: &quot;</span> + ex1);\r\n  }\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2009-09-30T14:57:29.587-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240681",
    "ThreadId": "70644",
    "Html": "<p>ps: I considered making this setting automatic - in other words it would get set with the content of the file.&nbsp; But with Unicode and other text encodings, it's not trivial to say whether a file is &quot;a text file&quot; or &quot;a binary file&quot;.&nbsp; It sort of loses its meaning.&nbsp; Because of that, the&nbsp;property of entries within a zip file has fallen into disuse now.&nbsp; But I guess older mainframe apps still use it.&nbsp; The <strong>IsText </strong>property was added a while back to DotNetZip to satisfy a person who was sending zips to a mainframe.</p>\r\n<p>I could go part-way, and mark an entry as text if all of the bytes are in the ASCII range, I guess.&nbsp; But I didn't want to do a half-job, and examining each byte would be a huge performance hit.&nbsp; I could also mark an entry as text based on the extension of the entry (like *.txt gets marked as text), but that would also not be very complete.&nbsp; So in the end I made it a manual property that the application must set. &nbsp;&nbsp;</p>",
    "PostedDate": "2009-09-30T16:03:11.97-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240959",
    "ThreadId": "70644",
    "Html": "<p>Great!</p>\r\n<p>I've added the suggested change and now is awaiting the results from Mainframe guys, hopefully it will do the trick!</p>\r\n<p>Thanks for your help,</p>\r\n<p>miketro</p>\r\n<p>&nbsp;</p>\r\n<pre style=\"font-size:1em;font-family:Consolas, 'Courier New', Courier, monospace\"><span style=\"color:#0000ff\"><br></span></pre>",
    "PostedDate": "2009-10-01T09:00:41.307-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]