Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add From Folder #3

Open
cyberzilla opened this issue Feb 21, 2021 · 1 comment
Open

Add From Folder #3

cyberzilla opened this issue Feb 21, 2021 · 1 comment

Comments

@cyberzilla
Copy link

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

@wqweto
Copy link
Owner

wqweto commented Feb 21, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants