{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "",
    "ClosedDate": null,
    "CommentCount": 0,
    "Custom": null,
    "Description": "In my code I have a method:\n```\npublic bool CreateZIP(string ListStep)\n{\n\tLogger logger = LogManager.GetLogger(\"Task:CreateZIP\" + this.TaskGuid);\n\n\tusing (ZipFile zip = new ZipFile())\n\t{\n\t\tzip.AlternateEncoding = System.Text.Encoding.GetEncoding(\"cp866\");\n\t\tzip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always;\n\n\t\t...\n\t\tzip.AddFile(...) loop\n\t\t...\n\n\t\tzip.MaxOutputSegmentSize = Properties.Settings.Default.ZIPSizeLimit * 1024 * 1024;\n\n\t\tstring zipFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @\"zip-tmp\");\n\t\tstring TaskZipFolder = Path.Combine(zipFolder, this.TaskGuid);\n\n\t\ttry\n\t\t{\n\t\t\tif (!Directory.Exists(zipFolder)) Directory.CreateDirectory(zipFolder);\n\t\t\tif (!Directory.Exists(TaskZipFolder)) Directory.CreateDirectory(TaskZipFolder);\n\n\t\t\tzip.TempFileFolder = Path.GetTempPath();\n\t\t\tzip.Save(Path.Combine(TaskZipFolder, this.TaskGuid + @\".zip\"));\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tlogger.Fatal(\"Unable to save ZIP into ({0}): {1}\", Path.Combine(TaskZipFolder, this.TaskGuid + @\".zip\"), e.ToString());\n\t\t\tthrow;\n\t\t}\n\t}\n\treturn true;\n}\n```\n\nThis code is running on remote server from domain user 'gfo-svc' from 'C:\\Courier\\WD' directory.\nEach object instance has it's GUID, for example 'e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55'\nSo the 'zipFolder' variable value is 'C:\\Courier\\WD\\zip-tmp' and 'TaskZipFolder' value is 'C:\\Courier\\WD\\zip-tmp\\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55'\n\nWhen this code tries to run it fails with this stack trace:\n```\nUnable to save ZIP into (C:\\Courier\\WD\\zip-tmp\\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55\\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55.zip): System.UnauthorizedAccessException: Access to the path is denied.\n   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\n   at System.IO.__Error.WinIOError()\n   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)\n   at Ionic.Zip.ZipSegmentedStream.TruncateBackward(UInt32 diskNumber, Int64 offset)\n   at Ionic.Zip.ZipEntry.Write(Stream s)\n   at Ionic.Zip.ZipFile.Save()\n   at Ionic.Zip.ZipFile.Save(String fileName)\n   at Worker.Task.CreateZIP(String ListStep) in Worker.cs:line 844\n```\n\nBut in the 'C:\\Courier\\WD\\zip-tmp\\e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55' folder I can see file 'e1664582-1bbc-4a9f-a9fe-e7ce4a0a8a55.z01', so the first part of archive was saved before failure.\n\n'gfo-svc' user has ownership on 'C:\\Courier\\WD' directory and my code could create 'zip-tmp' directory if it is not exists, and GUID-named directory in it. So the problem is not in Windows Security permissions.\nUAC on this remote server is disabled.\n\nWhat could I do wrong? What might be wrong with my environment? What could I do?",
    "LastUpdatedDate": "2014-09-30T05:07:21.197-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Unassigned",
      "Severity": 0,
      "Id": 0
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2014-03-07T06:53:31.703-08:00",
    "Status": {
      "Name": "Proposed",
      "Id": 1
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "System.UnauthorizedAccessException: Access to the path is denied. while Saving zip to Disk",
    "Type": {
      "Name": "Unassigned",
      "Id": 5
    },
    "VoteCount": 1,
    "Id": 16748
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "I seem to be experiencing the same problem whereby I get unauthorized access to the zip temporary file when execution reaches **zip.Save()**\n``\n(TRUNCATED TO 500 CHARS): System.UnauthorizedAccessException: Access to the path 'c:\\windows\\system32\\inetsrv\\DotNetZip-r0ayp1u5.tmp' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ct\n``\nHas anyone figured out this issue yet?",
      "PostedDate": "2014-09-30T04:32:42.487-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Ok, The solution to my problem was simple when I thought about it for a while.\r\n\r\n**zip.Save()** - attempts to save file in the working directory of executing process\n - which in my case defaulted to 'c:\\windows\\system32\\inetsrv\\'\n - which in turn get denied by the system\r\n\r\nBy providing absolute path to where I want my zip file to be saved everyone is kept happy.\r\n\r\n**zip.Save(dirPath + zipName)** - and that is all\n",
      "PostedDate": "2014-09-30T05:07:21.197-07:00",
      "Id": -2147483648
    }
  ]
}