Jump to content

make a zip file and add contents of a folder in it


Recommended Posts

Thanks for the alternatives but none of them have

Func _Zip_AddFolderContents()

how do i add contents of a folder to a zip file invisible mode?

i have added some new lines in function and now it shows the window only for 1 second.

Func _Zip_AddFolderContents($hZipFile, $hFolder, $flag = 1)
    Local $DLLChk = _Zip_DllChk()
    If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
    If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
    If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
    If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\"
    $files = _Zip_Count($hZipFile)
    WinSetState("Compressing...", "", @SW_HIDE)
    $oApp = ObjCreate("Shell.Application")
    WinSetState("Compressing...", "", @SW_HIDE)
    $oFolder = $oApp.NameSpace($hFolder)
    WinSetState("Compressing...", "", @SW_HIDE)
    $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oFolder.Items, 1028)
    WinSetState("Compressing...", "", @SW_HIDE)
    $oFC = $oApp.NameSpace($hFolder).items.count
    WinSetState("Compressing...", "", @SW_HIDE)
    While 1
        WinSetState("Compressing...", "", @SW_HIDE)
        If $flag = 1 then _Hide()
        If _Zip_Count($hZipFile) = ($files+$oFC) Then ExitLoop
        Sleep(10)
    WEnd
    Return SetError(0,0,1)
EndFunc   ;==>_Zip_AddFolderContents

but still not perfect, and the Alternative UDFs does not have _Zip_AddFolderContents()

Link to comment
Share on other sites

The 'Compressing...' window is not the same as the progress dialog in my testing. I have been unable to properly suppress that window. The progress dialog is suppressed, for example, when extracting a zip file. I believe the 'Compressing...' window is created by the zipfldr.dll library, while the true progress dialog is created (or suppressed) by the shell itself.

Edited by wraithdu
Link to comment
Share on other sites

Adrive,

i changed the line as suggested, but the result is same as before.

the documentation which you provided, i have read that too.

now i am totally confused what to do.

any one please help if you can.

Works fine here. Are you sure you modified it accordingly?

Here's the modified function from the UDF:

Func _Zip_AddFolderContents($hZipFile, $hFolder, $flag = 0)
    Local $DLLChk = _Zip_DllChk()
    If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
    If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
    If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
    If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\"
    $files = _Zip_Count($hZipFile)
    $oApp = ObjCreate("Shell.Application")
    $oFolder = $oApp.NameSpace($hFolder)
    $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oFolder.Items, $flag)
    $oFC = $oApp.NameSpace($hFolder).items.count
    While 1
        If _Zip_Count($hZipFile) = ($files+$oFC) Then ExitLoop
        Sleep(10)
    WEnd
    Return SetError(0,0,1)
EndFunc   ;==>_Zip_AddFolderContents

Note the line that calls _Hide is removed, as it's pointless. And that the CopyHere() call now passes $flag, and that $flag's default value is now 0. Now to use this function, pass it the flags you want to use, which in your case is the value 4 (there's many other options too).

And here is a sample call to the function:

#include <Zip.au3>

_Zip_AddFolderContents("c:\test.zip", "c:\tmp", 4)

Works perfect on my end, no copy progress dialog. removing the flag brings the dialog back.

Also note that if the files exist, you'll still get a prompt saying the files exist, in which case you need to use the flag value: 20 which answers yes to all dialog questions and suppresses the progress.

Edited by SublimePorte
Link to comment
Share on other sites

  • Moderators

SublimePorte,

Of interest, what OS are you using? As wraithdu has pointed out above, the dialog appears to come from different places depending on OS.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...