I have an embedded resource in my .exe that is a zip file, I would like to move it out of the resources and unzip it to a specific folder.
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btn_Install.Click
Dim Dir_File As String = "C:\FTB"
Dim Dir_Temp As String = "C:\Temp\Unleashed.zip"
System.IO.File.WriteAllBytes(Dir_Temp, My.Resources.Unleashed)
Dim directorySelected As DirectoryInfo = New DirectoryInfo(Dir_Temp)
End Sub
But I have no way of extracting the the .zip file to a directory. So all I need now is a way to actual extract the .zip.
I tried this:
Dim directorySelected As DirectoryInfo = New DirectoryInfo(Dir_Temp)
For Each fileToDecompress As FileInfo In directorySelected.GetFiles("Unleashed.zip")
Using OriginalFileStream As FileStream = fileToDecompress.OpenRead()
Using decompressedFileStream As FileStream = File.Create(Dir_File & "\Unleashed")
Using decompressionStream As GZipStream = New GZipStream(OriginalFileStream, CompressionMode.Decompress)
decompressionStream.CopyTo(decompressedFileStream)
End Using
End Using
End Using
Next
But all that did was give me an error about a magic number. Any help is very much appreciated.