Unzip files programmatically in VB .NET

This article explains about How to unzip a zip file using VB.net programming, it is one of the easiest ways to unzip a file using VB.Net because it doesn't require any specific system configuration or installation. The only prerequisite is to have basic syntax knowledge about the VB.NET programming language. So let's begin and follow the below step by step process to make this implementation easier "unzip a file using VB.Net programming"

Step 1- Declare variable to assign the file name
Dim tZipFile As String = "strZipFile.zip"

Step 2- Declare variable to assign the folder path where zip file exists
Dim tLNDSite As String = "D:\DOCUMENTS\"

Step 3- Declare variable to assign the fully qualified path
Dim tZipFilePath As String = tLNDSite + tZipFile

Step 4- Create an Instance of the shell object, target folder, and input file
Dim sh As New Shell32.Shell()
Dim TargetFolder As Shell32.Folder = sh.NameSpace(tLNDSite)
Dim InputZipFile As Shell32.Folder = sh.NameSpace(tZipFilePath)

Step 5- Extracting all files from the source file, supressing the progress bar:
byte[] UncompressedData = System.IO.File.ReadAllBytes(fullFile);
MemoryStream CompressedData = new MemoryStream();
GZipStream GZipper = new GZipStream(CompressedData, CompressionMode.Compress, false);
GZipper.Write(UncompressedData, 0, UncompressedData.Length);
GZipper.Dispose();
File.WriteAllBytes(fullFile + ".gz", CompressedData.ToArray());
CompressedData.Dispose();

Summary
In this article, you have learned about "How to unzip the file using VB.NET Programming" I hope you would find this article helpful. Any comment/suggestion or feedback is most welcome so that I can improve your reading experience.

Post a Comment

0 Comments