VszLib icon indicating copy to clipboard operation
VszLib copied to clipboard

Add From Folder

Open cyberzilla opened this issue 4 years ago • 1 comments

Is possible to add from folder @wqweto ?

i have try:

With New cVszArchive
        .AddFile App.Path & "\plugins\*.*"
        .Parameter("x") = 3 '-- CompressionLevel = Fast
        .CompressArchive App.Path & "\plugins.7z"
End With
MsgBox "pluginsx.7z created ok", vbExclamation

but not working

cyberzilla avatar Feb 21 '21 02:02 cyberzilla

AddFile method as the name implies can add a single file and there is no AddFolder method available but it is trivial to enum files in a folder and call AddFile for each one of them like this

Dim vElem As Variant

With New cVszArchive
        ' .AddFile App.Path & "\plugins\*.*"
        For Each vElem In CreateObject("Scripting.FileSystemObject").GetFolder(App.Path & "\plugins").Files
            .AddFile vElem.Path
        Next
        .Parameter("x") = 3 '-- CompressionLevel = Fast
        .CompressArchive App.Path & "\plugins.7z"
End With
MsgBox "pluginsx.7z created ok", vbExclamation

Another option is to implement your custom EnumFiles function similar in usage as the code above if you need to recursively enumerate files in all subfolders or filter on a wilcard mask or whatever your needs be.

Check out EnumFiles function in vbimg2pdf project for such helper function using built-in Dir function.

Check out pvEnumFiles function in ZipArchive project for a such helper function based on FindFirst/NextFile API functions.

wqweto avatar Feb 21 '21 10:02 wqweto