這個小程式,須要用到第三方元件
請再程式裡的連結中下載
測試後已知的條件
1.中文檔名會有問題
2.用其他軟體壓成 ZIP 也是可以解得開
3.壓成非 ZIP 再改副檔名是沒有用的
Code Snip and Obj. download link.
Imports Ionic.Zip
Public Class Form1
Private Sub btnZip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZip.Click
Using zip As New ZipFile()
zip.AddDirectory("C:\T1")
zip.Save("C:\T1\my.zip")
MsgBox("Files zipped")
End Using
End Sub
Private Sub btnUnzip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnzip.Click
Dim PathArray As String() = {"C:\T1\my.zip", "C:\T2"}
UnzipFile(PathArray)
End Sub
Private Sub UnzipFile(ByVal args As String())
Using zip As ZipFile = ZipFile.Read(args(0))
Dim entry As ZipEntry
For Each entry In zip
entry.Extract(args(1), ExtractExistingFileAction.OverwriteSilently)
System.Threading.Thread.Sleep(20)
Next
End Using
End Sub
End Class
沒有留言:
張貼留言