Vb.net Zip and Unzip (Avoid using \\.\ error)

Nov 22, 2012 at 2:40 PM
Edited Nov 22, 2012 at 3:08 PM

This seems so simple, but I've searched Google for hours with no luck.

I've downloaded and implemented DotNetZip into my project in Visual Studio 2012 just fine.

Here is the code I'm trying to do-


Referenced Strings-

Dim Username As String = Environment.UserName
Dim AppData As String = "C:\Users\" & Username & "\AppData\Roaming"

Zip/Unzip Subs-

Public Sub MyZip(ByVal ContentFolder As String, ByVal CreateZip As String)
        Using zip As ZipFile = New ZipFile()
        End Using
    End Sub

Public Sub MyExtract(ByVal ZipToUnpack As String, ByVal UnpackDirectory As String)
        Using zip As ZipFile = ZipFile.Read(ZipToUnpack)
            Dim e As ZipEntry
            For Each e In zip
                e.Extract(UnpackDirectory, ExtractExistingFileAction.OverwriteSilently)
        End Using
    End Sub

How I'm calling the Subs-

MyExtract(AppData & "\test.zip", AppData & "\testdirectory")

MyZip(AppData & "\testdirectory", AppData & "\test.zip")

Now, whenever I try to run this, my program freezes for about 3 seconds and then runs like normal. But once I get to the "MyExtract" or "MyZip" calling, I get this error -

"FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path."

I've tried, Dim testzip As String = AppData & "\test.zip" and then calling testzip in case it was because of the "AppData" variable.

I wouldn't ask such a simple question but everywhere else seems to fail me.

I am using Ionic.zip v1.9.1.8