[
  {
    "Id": "123244",
    "ThreadId": "37146",
    "Html": "Thanks for this potentially fantastic library. <br>\r\nHowever I'm having problems getting it to work&nbsp;in my situation. <br>\r\nIn my VB ASP.NET project I'm trying to zip up a binary file and attach to an email, send&nbsp;the zip&nbsp;then delete the zip. <br>\r\n1. When the e-mail arrives, the attached ZIP file is empty, it's like the ZIP file can't add a network file to the zip file on the network. <br>\r\n2. When I try and delete the ZIP file at the end, it's still locked.&nbsp;I can't see a 'Close' function to unlock it, only Dispose, which doesn't unlock it. <br>\r\nThanks for any help you can provide. <br>\r\nWill.<br>\r\n<br>\r\nHere's a portion of the code:<br>\r\n<br>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">Dim</span></span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">As</span></span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">New</span></span><span style=\"font-size:13px\"> ZipFile(</span><span style=\"font-size:13px;color:#800000\"><span style=\"font-size:13px;color:#800000\">&quot;<span style=\"font-size:13px;color:#800000\"><span style=\"font-size:13px;color:#800000\"><a>\\\\server1\\ftproot\\Licence\\Engineer\\</a></span></span>1002.zip&quot;</span></span><span style=\"font-size:13px\">)<br>\r\nzip.AddFile<span style=\"font-size:13px\">(<span style=\"color:#800000\"><span style=\"color:#800000\">&quot;<span style=\"color:#800000\"><span style=\"color:#800000\"><a>\\\\server1\\ftproot\\Licence\\Engineer\\</a></span></span>1002.inf&quot;</span></span>)</span><br>\r\nzip.Save()<br>\r\n<br>\r\n<span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">Dim </span></span><span style=\"font-size:13px\">mail </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">As</span></span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">New</span></span><span style=\"font-size:13px\"> System.Net.Mail.MailMessage<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">Dim</span></span><span style=\"font-size:13px\"> attachment </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">As</span></span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">New</span></span><span style=\"font-size:13px\"> System.Net.Mail.Attachment(<span style=\"font-size:13px;color:#800000\">&quot;</span><a><span style=\"font-size:13px;color:#800000\">\\\\server1\\ftproot\\Licence\\Engineer\\</span></a><span style=\"font-size:13px;color:#800000\">1002.zip&quot;</span></span><span style=\"font-size:13px\">)<br>\r\n</span><span style=\"font-size:13px\">mail.Attachments.Add(attachment)<br>\r\n<span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\"><br>\r\nDim</span></span><span style=\"font-size:13px\"> mClient </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">As</span></span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">New</span></span><span style=\"font-size:13px\"> System.Net.Mail.SmtpClient<br>\r\nmClient.Host = </span><span style=\"font-size:13px;color:#800000\"><span style=\"font-size:13px;color:#800000\">&quot;ourEMailServer&quot;<br>\r\n</span></span><span style=\"font-size:13px\">mClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials()<br>\r\nmClient.Send(mail)<br>\r\n<br>\r\n<span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">If</span></span><span style=\"font-size:13px\"> File.Exists(<span style=\"color:#800000\">&quot;</span><a><span style=\"font-size:13px;color:#800000\">\\\\server1\\ftproot\\Licence\\Engineer\\</span></a><span style=\"font-size:13px;color:#800000\">1002.zip&quot;</span></span><span style=\"font-size:13px\">) </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">Then<br>\r\n</span></span><span style=\"font-size:13px\">&nbsp;&nbsp;&nbsp;&nbsp;File.Delete(<span style=\"color:#800000\">&quot;</span><a><span style=\"font-size:13px;color:#800000\">\\\\server1\\ftproot\\Licence\\Engineer\\</span></a><span style=\"font-size:13px;color:#800000\">1002.zip&quot;</span></span><span style=\"font-size:13px\">)<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">End</span></span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\">If<br>\r\n</span></span></span></span></span>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2008-10-06T11:32:46.787-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "123353",
    "ThreadId": "37146",
    "Html": "<p>Hmm, I don't know what the problem is, but can you please wrap your use of the ZipFile in a using clause, eg: </p>\r\n<pre>        Dim ZipToCreate As String = &quot;\\\\server1\\ftproot\\whatever.zip&quot;\r\n\r\n        If File.Exists(ZipToCreate) Then\r\n            'Console.WriteLine(&quot;Deletting existing zip file: {0}&quot;, ZipToCreate)\r\n            File.Delete(ZipToCreate)\r\n        End If\r\n\r\n        'Console.WriteLine(&quot;Creating new zip file: {0}&quot;, ZipToCreate)\r\n\r\n        Using zip As ZipFile = New ZipFile(ZipToCreate)\r\n          zip.AddFile(&quot;\\\\server1\\ftproot\\whatever\\you\\like.txt&quot;) \r\n          zip.Save()\r\n        End Using\r\n\r\n        ' at this point the zip file should exist, and should be readable. \r\n\r\n</pre>\r\n",
    "PostedDate": "2008-10-06T17:09:45.057-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]