Unzip file in Vb.Net
-
Here is some code that may help if you would like to unzip files in Vb.Net. The NZipLib.dll is required. Public Function UnZipFile(ByVal FileName As String, ByVal DirName As String) As String Dim s As ZipInputStream = New ZipInputStream(File.OpenRead(FileName)) Dim theEnTry As ZipEntry Dim filePath As String = Path.GetFileNameWithoutExtension(FileName) theEnTry = s.GetNextEntry() Dim di As New DirectoryInfo(DirName & filePath) If Not di.Exists Then di.Create() End If Dim count As Long While Not (theEnTry Is Nothing) Dim fs As FileStream = File.Create(DirName & filePath & "\" & theEnTry.Name) Dim nBytes As Integer Dim data() As Byte = New Byte(theEnTry.Size) {} Try nBytes = s.ReadByte() count = 1 While nBytes <> -1 Or count < (theEnTry.Size - 1) fs.WriteByte(nBytes) nBytes = s.ReadByte() count = count + 1 End While Catch ex As Exception MsgBox(ex.ToString) End Try fs.Close() theEnTry = s.GetNextEntry() End While s.Close() End Function Hope this helps you. Fishbone365