Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27472

VS 2010 DotNetZip UnZip/Zip with file locations

$
0
0
I've got the problem narrowed down, I just don't know how to fix it.

Here is an example code-

Variables for example:
Code:

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

Zip and UnZip subs:
Code:

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

Code:

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)
            Next
        End Using
    End Sub

How I call the subs:
Code:

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

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

All this works fine, but the problem is that DotNetZip will not take file locations in this form. I get this weird "FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path." error. If I just put the zip and folder names (instead of locations + names) it works fine but only looks in it's local directory. How do I get it to function as I need it to?

Viewing all articles
Browse latest Browse all 27472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>