This project is read-only.

Network AddFile problem

Oct 6, 2008 at 7:32 PM
Edited Oct 6, 2008 at 7:33 PM
Thanks for this potentially fantastic library.
However I'm having problems getting it to work in my situation.
In my VB ASP.NET project I'm trying to zip up a binary file and attach to an email, send the zip then delete the zip.
1. 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.
2. When I try and delete the ZIP file at the end, it's still locked. I can't see a 'Close' function to unlock it, only Dispose, which doesn't unlock it.
Thanks for any help you can provide.

Here's a portion of the code:


Dim zip As New ZipFile("\\server1\ftproot\Licence\Engineer\")

Dim mail As New System.Net.Mail.MailMessage
Dim attachment As New System.Net.Mail.Attachment("\\server1\ftproot\Licence\Engineer\")

mClient As New System.Net.Mail.SmtpClient
mClient.Host =
mClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials()

If File.Exists("\\server1\ftproot\Licence\Engineer\") Then
End If


Oct 7, 2008 at 1:09 AM

Hmm, I don't know what the problem is, but can you please wrap your use of the ZipFile in a using clause, eg:

        Dim ZipToCreate As String = "\\server1\ftproot\"

        If File.Exists(ZipToCreate) Then
            'Console.WriteLine("Deletting existing zip file: {0}", ZipToCreate)
        End If

        'Console.WriteLine("Creating new zip file: {0}", ZipToCreate)

        Using zip As ZipFile = New ZipFile(ZipToCreate)
        End Using

        ' at this point the zip file should exist, and should be readable.