我梦到这样的代码
声明功能ZipFolder库“ zipeasy.dll”
(SourceFolder,DistZipeName)
Private sub Command1_Click()
ZipFolder "C:\MyFolder\", "C:\MyZipdeFolder.zip")
End Sub
很多年我都尝试这样做,但是没有任何反应 所有类似的解决方案都非常复杂 为什么,为什么以及为什么没有像我在这里建议的那样简单的解决方案?
答案 0 :(得分:0)
您可以尝试ZipArchive
项目-具有ASM速度的zip单类纯VB6库
首先下载cZipArchive.cls
并将其添加到您的VB6项目中,然后您就可以使用此ZipFolder
功能
Private Function ZipFolder( _
SourceFolder As String, _
DistZipeName As String, _
Optional LastError As String) As Boolean
On Error GoTo EH
With New cZipArchive
If Not .AddFromFolder(SourceFolder & IIf(Right$(SourceFolder, 1) <> "\", _
"\", vbNullString) & "*.*", Recursive:=True) Then
LastError = .LastError
GoTo QH
End If
If Not .CompressArchive(DistZipeName) Then
LastError = .LastError
GoTo QH
End If
End With
'--- success
ZipFolder = True
QH:
Exit Function
EH:
LastError = Err.Description
Resume QH
End Function
当然,您可以使用该类做更多的事情(例如以zip列出文件,提取文件,显示操作进度,仅压缩到内存,AES加密级别),并且您可以在repo's root中的README.md
或vbzip
命令行实用程序的源代码中的VbZip 0.2.3 (c) 2017-2018 by wqweto@gmail.com (12.1.2018 17:15:52)
Usage: vbzip.exe <command> [-options...] <archive_file> [files]...
e.g. vbzip.exe a backup.zip doc1.txt reports*.xls
Commands:
a add files to archive
l list archive contents
t test archive integrity
x extract files from archive
Options:
-r recurse subfolders
-e include empty folders
-m LEVEL compression level [default: 6]
-o OUTPUT output folder to extract to
-i no percentage indicator
-y assume yes to all questions
-p PASSWORD password used to encrypt/decrypt files
-mem METHOD encryption method
-so output to stdout
-si NAME input from stdin zip to NAME in archive
可以压缩/提取zip归档文件和更多内容
checked