B4J Question Zipping a folder

khwarizmi

Active Member
Licensed User
Longtime User
Hi all

I used ArchiverPlus libray to zip a folder as follows :

B4X:
Dim arc As ArchiverPlusZip
arc.ZipCompression = True
Dim Const InputFolder As String = File.Combine("d:\1", "") & "\"
arc.AddFolderToZip(InputFolder,InputFolder & "abc.zip", "")
Do While arc.ZipResultCode = arc.ZIP_RESULT_WORKING
    Sleep(0)
Loop

But the output is a correpted zip file, Where is my mistake?
 
Solution
B4X:
    Dim arc As ArchiverPlusZip
    arc.ZipCompression = True
    arc.ZipExecutionMode = arc.ZIP_EXECMODE_ASYNCHRONOUS
    Dim InputFolder As String = "D:\1"
    arc.AddFolderToZip(InputFolder, File.Combine("D:\","abc.zip"), "ZIP")
    Wait For ZIP_ZipResult(Result As Int, ErrorMsg As String)
    Log($"ZipResult #${Result},${ErrorMsg}"$)

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim arc As ArchiverPlusZip
    arc.ZipCompression = True
    arc.ZipExecutionMode = arc.ZIP_EXECMODE_ASYNCHRONOUS
    Dim InputFolder As String = "D:\1"
    arc.AddFolderToZip(InputFolder, File.Combine("D:\","abc.zip"), "ZIP")
    Wait For ZIP_ZipResult(Result As Int, ErrorMsg As String)
    Log($"ZipResult #${Result},${ErrorMsg}"$)
 
Upvote 3
Solution

johnmie

Active Member
Licensed User
Longtime User
How to zip just all the files in a folder without the name of the folder on top?
I used to add file by file to the zip file, which sometimes caused an error.
There must be an easier way, I guess.
thanks for your help
 
Upvote 0
Top