I took the odd approach to embed 7zip into my exe and extract it in a tempfolder (and delete it afterwards).
Execution is hidden..
To bad is that it is rather big.
Announcement
Collapse
No announcement yet.
Example of creating ZIP file using Windows Shell posted in Source Code forum
Collapse
X
-
I had no problems zipping one file at a time with anywhere from five to over ninety files in this: Source Code Bundler v 3 handles PB 7/8/9/10 and CC 3/4/5/6 source code
(Yes, the routine is 'cut and paste' reuseable)
MCM
Leave a comment:
-
Hello,
'NOTE: the above copyhere method starts a seperate thread to do the copy
'so the command could return before the copy is finished, so we need to
'allow time to complete. Thus the next Sleep command.
sleep 2000 'increase for larger folders
Code:... LOCAL lNr, lInFiles, lOutFiles AS LONG ... ... lInFiles = oSourceFolder.Items().COUNT IF ERR THEN MSGBOX "error during the Count property in SourceFolder",,"Error:" & STR$(ERR) GOTO Terminate END IF ... ... vOptions = 1024 oTargetFolder.CopyHere(oItems, vOptions) lNr = 0 lOutFiles = 0 DO SLEEP 125 lOutFiles = oTargetFolder.Items().COUNT IF ERR THEN MSGBOX "error during the Count property in TargetFolder",,"Error:" & STR$(ERR) GOTO Terminate END IF INCR lNr LOOP UNTIL lNr > 240 OR lOutFiles >= lInFiles ' max.30 Sec timeout, ">=" there can be any files at "unzip" IF lNr => 240 THEN MSGBOX "timeout during CopyHere method",,"Error" GOTO Terminate END IF ...
P.S. For example, I have taken 30 seconds timeout.
But it can and longer lasts at unzip operation... then change it.Last edited by Alexander Holzer; 13 Nov 2008, 06:23 AM.
Leave a comment:
-
I haven't tested it, but it should be as simple as using the CopyHere method and swapping the target and source in the example code. (skip the first part of the example code that creates the zip file)
Leave a comment:
-
Unzip ?
Has anybody written the COM routine to Unzip a ZIP File? I wish I had some COM understanding to do it by I don't.
Leave a comment:
-
Not to add more confusion, but I must add this caveat.
Lets say the zip does not appear until its finished writing, this could not be true if the destination is on a USB drive.
Although normally faster than what you would see, but files appear on the drive, but are not written until Windows has processing time free to physically write it to the disk. (This is partly why if you go to eject, you may get the message that it can not safely eject yet)
Just some more fodder for thought
Leave a comment:
-
>But I wonder if the zip file would show up before it finished with the zipping
That's what I was wondering myself: if the Copyhere method closes the target file after each file in the list has been added, which forces a directory update, which causes the FindFirstChangeNotification() object to become signalled.
If it's doing that, then instead of handling multiple files thru one call to CopyHere, you could add the files one at a time, and only monitor FFCN() following the last call.
That would also let you do a nice 'progress bar' for the user, updating after each file.
MCM
Leave a comment:
-
Originally posted by William Burns View PostI have also seen a lot of people address this issue by putting the program in a waiting loop that looks for the new zip file to see if it exists before proceeding. But I wonder if the zip file would show up before it finished with the zipping. I know when I manually create a zip file, I can see the zip file before it stops when I zip a large folder. So I am doubtful if that would work %100 of the time.
William
Another thought, when the program is finished with the zipping, could may try to FileCopy to a dummy. If getting an Error back that would indicate the zip file hasn't been completely written yet. (Windows wouldn't allow a, Open file to be copied that was still being written too. Would it?)
FWIW.
==============================================
"All truth passes through three stages.
First, it is ridiculed.
Second, it is violently opposed.
Third, it is accepted as being self-evident."
Arthur Schopenhauer (1788-1860)
==============================================
Leave a comment:
-
ZipFolders can be installed to Pre-XP OS's too. I have the files and a BAT file to install it if needed. Back when I hated XP I had 2000 configured to do everything XP does except themes. Even App Compat works with a registry tweak.
Leave a comment:
-
I have also seen a lot of people address this issue by putting the program in a waiting loop that looks for the new zip file to see if it exists before proceeding. But I wonder if the zip file would show up before it finished with the zipping. I know when I manually create a zip file, I can see the zip file before it stops when I zip a large folder. So I am doubtful if that would work %100 of the time.
William
Leave a comment:
-
Thanks. I try to comment the code well that I post since the audience normally has varied experience levels.
... use of WaitForSingleObject()
William
Leave a comment:
-
Excellent job of commenting!
One thought....
Code:'NOTE: the above copyhere method starts a seperate thread to do the copy 'so the command could return before the copy is finished, so we need to 'allow time to complete. Thus the next Sleep command. sleep 2000 'increase for larger folders
Code:Method Synchronize <1610809346> ()
Or maybe, one of the properties you can get is either a threadid or thread handle, allowiing the use of WaitForSingleObject() ???
Or also maybe... you could set up a FindFirstChangeNotification object on the target file, and when the copy is complete and the directory updated the object will become signalled and you could stop waiting then?
MCMLast edited by Michael Mattias; 4 Sep 2008, 09:49 AM.
Leave a comment:
-
Right you are. Looks like the "Insert Link" icon puts "http://" in before you paste the link and I must have pasted my full link after that.
Thanks for the info. It's fixed now.
Leave a comment:
-
Leave a comment:
-
Example of creating ZIP file using Windows Shell posted in Source Code forum
I just posted an example of how to use the new PB9 COM to interface with Windows Shell to create a new ZIP file and copy a folder and all its contents to the ZIP file. (Using the built-in zip functions of Windows XP and above) It is in the source code forum here.
Post comments or questions here.
WilliamTags: None
Leave a comment: