[
  {
    "Id": "266290",
    "ThreadId": "77863",
    "Html": "<p>I've been using your DotNetZip library for a few months now and it's been working great. I just discovered today when saving files to an archive, that the NTFS file attributes are all cleared from the source files. Several of the files I'm archiving need the read-only attribute set to work properly. I've looked through the documentation and don't see anything about leaving the source file's attributes unaltered. What is interesting is when I extract the files, the archived files do have these attributes, so I don't understand why the original file would lose these. Any idea what causes this?</p>\r\n<p><br>I call the AddDirectory method for adding files to an archive and use the following signature:</p>\r\n<p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>ZipFile.AddDirectory(<span style=\"color:Blue\">string</span> directoryName, <span style=\"color:Blue\">string</span> directoryPathInArchive)\r\n</pre>\r\n</div>\r\n</p>\r\n<p>&nbsp;</p>\r\n<p>I'm using version 1.8.4.24 of the full library (Ionic.Zip.dll)</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks,</p>\r\n<p>Jim</p>",
    "PostedDate": "2009-12-11T08:08:25.85-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "266360",
    "ThreadId": "77863",
    "Html": "<p>I don't see that behavior in any of my tests.</p>\r\n<p>I also inspected the code, and there is only one place where the file attributes are written - that is in the extraction logic, where the original file attributes are restored.&nbsp; You said you observed that this worked for you.</p>\r\n<p>Attributes on the original source files are never set, within the DotNetZip library.</p>\r\n<p>Can you reproduce this in a very simple test case?&nbsp; I just tried and could not.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-11T10:48:50.777-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "266375",
    "ThreadId": "77863",
    "Html": "<p>Here's the code I tried.&nbsp; It did not show any change in the file attributes for the file that was contained in the directory that I zipped up.</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>    <span style=\"color:Blue\">public</span> <span style=\"color:Blue\">void</span> Run()\r\n    {\r\n        <span style=\"color:Blue\">string</span> zipfile = <span style=\"color:#A31515\">&quot;Restless.zip&quot;</span>;\r\n        <span style=\"color:Blue\">string</span> dir = <span style=\"color:#A31515\">&quot;RestlessDir&quot;</span>;\r\n        <span style=\"color:Blue\">if</span> (Directory.Exists(dir))\r\n        {\r\n            ClearReadOnly(dir);\r\n            Directory.Delete(dir, <span style=\"color:Blue\">true</span>);\r\n        }\r\n\r\n        Directory.CreateDirectory(dir);\r\n\r\n        <span style=\"color:Blue\">string</span> filename = <span style=\"color:#A31515\">&quot;ReadOnly.txt&quot;</span>;\r\n        <span style=\"color:Blue\">string</span> fullpath = Path.Combine(dir,filename);\r\n        <span style=\"color:Blue\">if</span> (File.Exists(fullpath))\r\n            File.Delete(fullpath);\r\n\r\n        <span style=\"color:Green\">// create the file</span>\r\n        <span style=\"color:Blue\">string</span> createText = <span style=\"color:#A31515\">&quot;Hello and Welcome&quot;</span> + Environment.NewLine;\r\n        File.WriteAllText(fullpath, createText);\r\n\r\n        <span style=\"color:Green\">// set the readonly bit </span>\r\n        <span style=\"color:Blue\">var</span> a = File.GetAttributes(fullpath);\r\n        a |= FileAttributes.ReadOnly;\r\n        File.SetAttributes(fullpath, a);\r\n\r\n        <span style=\"color:Green\">// get and display the attributes</span>\r\n        a = File.GetAttributes(fullpath);\r\n        System.Console.WriteLine(<span style=\"color:#A31515\">&quot;BEFORE file attrs: {0}&quot;</span>, a.ToString());        \r\n\r\n        <span style=\"color:Green\">// zip the directory</span>\r\n        <span style=\"color:Blue\">using</span> (<span style=\"color:Blue\">var</span> zip = <span style=\"color:Blue\">new</span> ZipFile())\r\n        {\r\n            zip.AddDirectory(dir, <span style=\"color:#A31515\">&quot;dir&quot;</span>);\r\n            zip.Save(zipfile);\r\n        }\r\n\r\n        <span style=\"color:Green\">// get and display the attributes again</span>\r\n        a = File.GetAttributes(fullpath);\r\n        System.Console.WriteLine(<span style=\"color:#A31515\">&quot;AFTER file attrs: {0}&quot;</span>, a.ToString());\r\n\r\n        <span style=\"color:Green\">// remove the directory</span>\r\n        ClearReadOnly(dir);\r\n        Directory.Delete(dir, <span style=\"color:Blue\">true</span>);\r\n    }\r\n\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2009-12-11T11:08:26.397-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "266405",
    "ThreadId": "77863",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>Thanks for the quick reply. I'm sorry I wasted your time because it turns out your library had nothing to do with my problem. I was copying the source folders to a backup directory in a separate thread which was clearing the file attributes. I thought I commented out everything associated with that folder copy operation, but turns out I did not.</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks again.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-11T12:20:42.247-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "266434",
    "ThreadId": "77863",
    "Html": "<p>No problem, glad you figured it out.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-11T13:26:53.903-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]