其他分享
首页 > 其他分享> > vb.net 使用 ionic.zip 压缩\解压缩 文件 文件夹

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

标签:vb,Sub,zip,Encoding,解压缩,ZipFile,zipF,String
来源: https://www.cnblogs.com/MadeInChinese/p/15069660.html