[
  {
    "Id": "181028",
    "ThreadId": "53775",
    "Html": "I'm getting an &quot;Illegal Characters in path&quot; exeption and I can't figure out why. <br>\r\n<br>\r\nHere is the code.......<br>\r\n<span style=\"font-size:13px;color:#0000ff\">void</span><span style=\"font-size:13px\"> AddFileToZip(</span><span style=\"font-size:13px;color:#0000ff\">string</span><span style=\"font-size:13px\"> FileName, </span><span style=\"font-size:13px;color:#0000ff\">string</span><span style=\"font-size:13px\"> ArchiveName)<br>\r\n{<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">    using</span><span style=\"font-size:13px\"> (</span><span style=\"font-size:13px;color:#2b91af\">ZipFile</span><span style=\"font-size:13px\"> zip = </span><span style=\"font-size:13px;color:#0000ff\">new</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#2b91af\">ZipFile</span><span style=\"font-size:13px\">())<br>\r\n    {<br>\r\n        zip.AddFile(@FileName.ToString());<br>\r\n        zip.Save(</span><span style=\"font-size:13px;color:#a31515\">&quot;myfile.zip&quot;</span><span style=\"font-size:13px\">);<br>\r\n    }<br>\r\n}<br>\r\n<br>\r\nHere is the Stack<br>\r\nSystem.ArgumentException was unhandled<br>\r\n  Message=&quot;Illegal characters in path.&quot;<br>\r\n  Source=&quot;mscorlib&quot;<br>\r\n  StackTrace:<br>\r\n       at System.IO.Path.CheckInvalidPathChars(String path)<br>\r\n       at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)<br>\r\n       at System.IO.Path.NormalizePath(String path, Boolean fullCheck)<br>\r\n       at System.IO.Path.GetFullPathInternal(String path)<br>\r\n       at System.IO.FileInfo..ctor(String fileName)<br>\r\n       at Ionic.Zip.ZipEntry.FigureCompressionMethodForWriting(Int32 cycle)<br>\r\n       at Ionic.Zip.ZipEntry.WriteHeader(Stream s, Int32 cycle)<br>\r\n       at Ionic.Zip.ZipEntry.Write(Stream outstream)<br>\r\n       at Ionic.Zip.ZipFile.Save()<br>\r\n       at Ionic.Zip.ZipFile.Save(String zipFileName)<br>\r\n       at WindowsFormsApplication1.Form1.AddFileToZip(String FileName, String ArchiveName) in C:\\Users\\Tony\\Documents\\Visual Studio 2008\\Projects\\WindowsFormsApplication1\\WindowsFormsApplication1\\Form1.cs:line 30<br>\r\n       at WindowsFormsApplication1.Form1.cmdStart_Click(Object sender, EventArgs e) in C:\\Users\\Tony\\Documents\\Visual Studio 2008\\Projects\\WindowsFormsApplication1\\WindowsFormsApplication1\\Form1.cs:line 51<br>\r\n       at System.Windows.Forms.Control.OnClick(EventArgs e)<br>\r\n       at System.Windows.Forms.Button.OnClick(EventArgs e)<br>\r\n       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br>\r\n       at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)<br>\r\n       at System.Windows.Forms.Control.WndProc(Message&amp; m)<br>\r\n       at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)<br>\r\n       at System.Windows.Forms.Button.WndProc(Message&amp; m)<br>\r\n       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)<br>\r\n       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)<br>\r\n       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br>\r\n       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)<br>\r\n       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br>\r\n       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br>\r\n       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br>\r\n       at System.Windows.Forms.Application.Run(Form mainForm)<br>\r\n       at WindowsFormsApplication1.Program.Main() in C:\\Users\\Tony\\Documents\\Visual Studio 2008\\Projects\\WindowsFormsApplication1\\WindowsFormsApplication1\\Program.cs:line 18<br>\r\n       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)<br>\r\n       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br>\r\n       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br>\r\n       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br>\r\n       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br>\r\n       at System.Threading.ThreadHelper.ThreadStart()<br>\r\n  InnerException: <br>\r\n</span>\r\n",
    "PostedDate": "2009-04-19T10:59:21.643-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "181253",
    "ThreadId": "53775",
    "Html": "The exception you are getting says, &quot;illegal characters in path&quot;.<br>\r\nSometimes the exception is what it says it is.  <br>\r\n<br>\r\nIt would help to know what characters are in the path. . .  <br>\r\nCan you use a debugger to verify that the pathname is what you think it should be?<br>\r\n<br>\r\nWhat is the name of the file that is generating this error?<br>\r\nDoes it happen with every file? <br>\r\n<br>\r\nI can reproduce the stacktrace you reported by using a filename that contains a \\t (tab) character.   <br>\r\n<br>\r\n<span style=\"color:#ff0000\">EDIT</span>: Also, I suspect your use of the @ prefix is unnecessary, and your use of the @ may be related to the error you are getting.  When prepended to a string literal, the @ tells the compiler to treat the string as verbatim.  In other words, @&quot;dir\\test\\file.txt&quot; is the same as &quot;dir\\\\test\\\\file.txt&quot;.    When prepended to an identifier (eg, FileName in your code), the @ prefix tells the compiler to that it is ok to use a keyword as an identifier.  C# keywords include things like &quot;class&quot;, &quot;bool&quot; or &quot;struct&quot;.  Using this prefix you can do something like this: <br>\r\n<pre>  bool @class= false;\r\n  while (! @class)\r\n  { \r\n    @class = DetermineSomeValue();\r\n  }\r\n</pre>\r\n<br>\r\nThe @ prefix for identifiers is intended to allow compatibility with other languages. The rule is: If you don't NEED to use a C# keyword as an identifier, don't.   <br>\r\n<br>\r\nYour use of the @ prefix is needless.  C# allows you to prefix any identifier with the @ prefix - it need not be a C# keyword.  But if it is not a keyword, then the @ prefix has no effect.  In other words, @FileName is the same as FileName.  <br>\r\n<br>\r\nYou may be thinking that you want the compiler to treat the contents of FileName as a verbatim string - in other words suppose that FileName contains &quot;c:\\temp\\test.txt&quot;. As you know, \\t is the tab character; that string is 14 characters long and has two TABs in it. With your use of the prefix, you may want the compiler to interpret that as &quot;c:\\\\temp\\\\test.txt&quot;, a string of length 16 with two backslashes in it.  But @FileName will not do this.  If you have single backslashes in the string referred to by FileName, you may need to do a FileName.Replace(&quot;\\&quot;,&quot;\\\\&quot;); <br>\r\n",
    "PostedDate": "2009-04-20T05:05:50.037-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "181269",
    "ThreadId": "53775",
    "Html": "Since the error occurred on the this call, <span style=\"font-size:13px\">zip.Save(</span><span style=\"font-size:13px;color:#a31515\">&quot;myfile.zip&quot;</span><span style=\"font-size:13px\">), I didn't even think of check the AddFile parameter which of course was the culprit.<br>\r\n<br>\r\nThanks!!!<br>\r\n-T<br>\r\n</span>\r\n",
    "PostedDate": "2009-04-20T05:57:24.683-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "181277",
    "ThreadId": "53775",
    "Html": "Ahh, I've been there. Glad you sorted it out.\r\n",
    "PostedDate": "2009-04-20T06:23:33.413-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]