vb.net 使用 ionic.zip 压缩\解压缩 文件 文件夹

'压缩文件
Public Sub zipCompressFile(SourceFilePathName As String, NewZipPathName As String)

'Dim zipF As New ZipFile(System.Text.Encoding.GetEncoding("GB18030"))
Dim zipF As New ZipFile(System.Text.Encoding.Default)
zipF.AddFile(SourceFilePathName, "")
zipF.Save(NewZipPathName)

End Sub

'压缩文件夹
Public Sub zipCompressFolder(SourcePath As String, NewZipPathName As String)

'Dim zipF As New ZipFile(System.Text.Encoding.GetEncoding("GB18030"))
Dim zipF As New ZipFile(System.Text.Encoding.Default)
AddHandler zipF.SaveProgress, AddressOf MySaveProgress
If Directory.Exists(SourcePath) Then
zipF.AddDirectory(SourcePath)
Threading.Thread.Sleep(0)
zipF.Save(NewZipPathName)
End If

End Sub

'zip解压全部文件
Public Sub zipExeAllDeComp(ByVal zipFpn As String, DeCompPath As String)
Dim Roptions As ReadOptions = New ReadOptions()
Roptions.Encoding = Encoding.Default '解决zip 解压中文名乱码
Using zip As ZipFile = ZipFile.Read(zipFpn, Roptions)
'zip.Password = "123456"

For Each entry As ZipEntry In zip
entry.Extract(DeCompPath)
Next
End Using
End Sub

上一篇:开发FireFox浏览器扩展(Extension)并实现与原生应用之间的消息传递(二)Windows+VB.Net


下一篇:VB List集合的使用