[
  {
    "Id": "288335",
    "ThreadId": "83969",
    "Html": "<p>Hi,</p>\r\n<p>&nbsp;</p>\r\n<p>I'm building a very simple program to compress several files inside a folder.</p>\r\n<p>I'm having troubles saving the output file, all folders permissions are OK there's nothing acessing the outup file, it gives me an error acessing the output file :S</p>\r\n<p><br>C:\\Documents and Settings\\xnbs190\\My Documents\\Visual Studio 2008\\Projects\\moveInteractionsMSG\\moveInteractionsMSG\\bi<br>n\\Release&gt;moveInteractionsMSG.exe<br>D:\\teste_temp_msg\\1-1H1Z8FQ.msg<br>D:\\teste_temp_msg\\1-1H2AIFF.msg<br>D:\\teste_temp_msg\\1-1H2RJ9A.msg<br>D:\\teste_temp_msg\\1-1H2RJM2.msg<br>D:\\teste_temp_msg\\1-1I9MZQ0.msg<br>D:\\teste_temp_msg\\1-1I9MZQA.msg<br>6<br><br>Unhandled Exception: System.IO.IOException: The process cannot access the file 'D:\\archivemsg\\msg_archive.zip' becaus<br>e it is being used by another process.<br>&nbsp;&nbsp; at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)<br>&nbsp;&nbsp; at System.IO.File.Delete(String path)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.Save()<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.Save(String fileName)<br>&nbsp;&nbsp; at ConsoleApplication1.Program.Main(String[] args) in C:\\Documents and Settings\\xnbs190\\My Documents\\Visual Studio<br>&nbsp;2008\\Projects\\moveInteractionsMSG\\moveInteractionsMSG\\Program.cs:line 60</p>\r\n<p>&nbsp;</p>\r\n<p>The code is very simple:</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileStream destFile = File.Create(output_zip_file);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileInfo[] files_to_compress = getDirectoryFiles(new DirectoryInfo(tmp_msg_dir));<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (FileInfo fi in files_to_compress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(tmp_msg_dir + &quot;\\\\&quot; + fi.ToString());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.AddFile(tmp_msg_dir + &quot;\\\\&quot; + fi.ToString(), dia_pasta);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(zip.Count);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Save(output_zip_file);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks in advance for any help.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-02-10T09:43:09.09-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "288342",
    "ThreadId": "83969",
    "Html": "<p>it's official.. i'm a dumbass.</p>\r\n<p>I was creating a FileStream for the outputfile and was saving the zip at the same time.</p>\r\n<p>FileStream destFile = File.Create(output_zip_file); -&gt; whas causing the problem</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-02-10T09:55:08.8-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "288452",
    "ThreadId": "83969",
    "Html": "<p>Glad you sorted it. Don't be too hard on yourself, We've all had those days.</p>",
    "PostedDate": "2010-02-10T13:29:50.37-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]