Understand compressed files in VB.NET

Can someone help me solve the problem of how to decompress the zip file in VB.Net?

Use “Imports Shell32” for instant messaging

if you look Take a look at this CodeProject article, it should help you. If you encounter a specific problem, you need to put the code and problem description in your problem.

From the above article:

Sub UnZip()
Dim sc As New Shell32.Shell()
'Create directory in which you will unzip your files .
IO.Directory.CreateDirectory("D:\extractedFiles")
'Declare the folder where the files will be extracted
Dim output As Shell32.Folder = sc.NameSpace("D:\extractedFiles")< br />'Declare your input zip file as folder .
Dim input As Shell32.Folder = sc.NameSpace("d:\myzip.zip")
'Extract the files from the zip file using the CopyHere command .
output.CopyHere(input.Items, 4)

End Sub

Link Folder.CopyHere method

Or, if you are using .Net 4.5, you can use ZipFile Class

Link example:

Imports System.IO
Imports System.IO.Compression

Module Module1

Sub Main()< br /> Dim startPath As String = "c:\example\start"
Dim zipPath As String = "c:\example\result.zip"
Dim extractPath As String = "c:\example\ extract"

ZipFile.CreateFromDirectory(startPath, zipPath)

ZipFile.ExtractToDirectory(zipPath, extractPath)
End Sub

End Module

Can someone help me solve the problem of how to decompress the zip file in VB.Net?

Use “Imports Shell32” for instant messaging

If you look at this CodeProject article, it should be something for you Help. If you encounter a specific problem, you need to put the code and problem description in your problem.

From the article above:

< pre>Sub UnZip()
Dim sc As New Shell32.Shell()
‘Create directory in which you will unzip your files .
IO.Directory.CreateDirectory(“D:\extractedFiles” )
‘Declare the folder where the files will be extracted
Dim output As Shell32.Folder = sc.NameSpace(“D:\extractedFiles”)
‘Declare your input zip file as folder.
Dim input As Shell32.Folder = sc.NameSpace(“d:\myzip.zip”)
‘Extract the files from the zip file using the CopyHere command .
output.CopyHere(input .Items, 4)

End Sub

Link Folder.CopyHere method

Or, if you are using .Net 4.5, you can use ZipFile Class

Link example:

Imports System.IO
Imports System.IO.Compression
< br />Module Module1

Sub Main()
Dim startPath As String = "c:\example\start"
Dim zipPath As String = "c:\example\result.zip"
Dim extractPath As String = "c:\example\extract"

ZipFile.CreateFromDirectory(startPath, zipPath)

ZipFile.ExtractToDirectory(zipPath, extractPath)
End Sub

End Module

Leave a Comment

Your email address will not be published.