Zip File As Embedded Resource - VB.Net Please Help

Jul 15, 2010 at 5:19 AM

Hi everyone I would like to put a zip file as an embedded resource on my program in Visual Basic .NET. I need this file to be unzipped or somehow access when my program runs so I'm able to use the files inside of that zip as normal embedded resources (I only want to zip them to compress the size of my file). I saw examples for this in C# but I only know VB.NET and I'm having trouble doing this. Please help, thanks in advance.

 

-GamerJer

Jul 21, 2010 at 10:26 PM
I am having the same problem. Seems to be the only examples are in C#. I know it's something about Stream, but I don't know where to start. -Conroy
Jul 22, 2010 at 3:32 AM

Yeah this is really being a pain for me as well.

Jul 22, 2010 at 7:33 PM
http://www.vbforums.com/showthread.php?p=3847866#post3847866 This thread helped me, hopefully it will help you too!
Coordinator
Jul 28, 2010 at 12:45 PM
If you provide some VB sample code showing what worked for you, I can add it to the documentation so as to help others in the future.
Jul 28, 2010 at 3:25 PM
Edited Jul 28, 2010 at 3:27 PM
' This creates the stream from the resource
Using s As Stream = Me.GetType().Assembly.GetManifestResourceStream(Me.GetType(), "FILENAME.zip") 'Change to your .ZIP in the resources
Dim TargetDir As String = "C:\" 'Naturally adjust this to suit your needs.
Using zip1 As ZipFile = ZipFile.Read(s)
AddHandler zip1.ExtractProgress, AddressOf MyExtractProgress ' I'm guessing this is optional if you want to show progress....
Dim e As ZipEntry
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each File In zip1
File.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently) ' This is what will actually write your files out
Next
End Using 'zip1
End Using 'Stream