erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 1, 2009 4:10:17 GMT -5
Perfect! BUT my problem is "I have ONE zip file, with 3 different folders in it. If checkbox 1 checked, I have to unzip, 1-st folder, if checkbox 2 checked, i have unzip 2-nd folder, if checkbox 3 checked, i have to unzip 3-d folder. Sometimes checkbox 1 ONLY can be checked, sometimes checkboxes 1&2,sometimes 1&3, or sometimes 1,2,3" How can I get count of files in 1,1+2,1+3 or 1+2+3 folders, BEFORE I start unzip them, to show COMMON progress? Bkz I (as I understand) unzip folders in separate blocks, bkz they have different RootDir. So as I understand I cant unzip them in ONE block. Do you understand me?
|
|
|
Post by Kevin on Mar 1, 2009 9:03:58 GMT -5
It depends...
Can the DestDir property be different for each one that you check, or will the DestDir always be the same for each one?
1) ===== If DestDir is same for all three ================= If the DestDir is the same for all three, then do it this way. Lets say the user picked Favorites and Contacts but not Mail.
VCLZip.DestDir := 'c:\somedir\mydir'); VCLZip.RelativePathList.Add('Favorites'); VCLZip.RalativePathList.Add('Contacts'); VCLZip.FilesList.Add('Favorites\*'); VCLZip.FilesLIst.Add('Contacts\*'); VCLZip.UnZip;
This way you only have to call UnZip one time. What you put in the RelativePathsList is like having many RootDirs.
2) ======== If DestDir can be different for each ============== If DestDir can be different for each one that the user can check then get the number of files about to be unzipped like this...
// First, define your OnStartUnzipInfo event and put the following code in it. If CountingFiles is true, this will be called each time Unzip // is called but will only increment FileCount and then stop procedure MyOnStartUnZipInfo(...NumFiles...StopNow...); begin if (CountingFiles) then begin FileCount := FileCount + NumFiles; StopNow := True; // This stops unzipping before it starts end end;
Before the code where you actually call Unzip do this to get the FileCount that will be unzipped:
CountingFiles := True; FileCount := 0; If (Favorites.Checked) then begin FilesList.Add('Favorites\*'); UnZip; end; If (Contacts.Checked) then begin FilesList.Add('Favorites\*'); UnZip; end; If (Mail.Checked) then begin FilesList.Add('Mail\*'); UnZip; end; CountingFiles := False;
Now FileCount has the number of files that will be unzipped. Now you can go ahead and unzip like you normally would.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 1, 2009 14:13:53 GMT -5
DestDir is different for each one. Of course. Favorites I should restore to one place, "contacts" to another and so on.
|
|
|
Post by Kevin on Mar 1, 2009 14:24:39 GMT -5
OK, see the second option in my previous post. I was modifying it while you were replying.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 1, 2009 15:21:18 GMT -5
Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!Cool! Clear! Thank you!!!
|
|
|
Post by Kevin on Mar 1, 2009 15:31:54 GMT -5
In OnEndUnZip. This is called each time a file has just been unzipped. So if there were 100 files to unzip, then in OnEndUnZip you would bump up your progress meter 1%. If there were 50 files you would bump it up 2%.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 1, 2009 16:03:12 GMT -5
And now I have to count zipping progress manually too ? Waht will you say about ...StartZipInfo(Sender: TObject; NumFiles: Integer; TotalBytes: Comp; var EndCentralRecord: TEndCentral; var StopNow: Boolean); begin FilesToZip:=NumFiles; end;
....StartZip(.....) begin // Which type? ..... inc(Zipped); Gauge2.Progress := trunc(Zipped*100/FilesToZip); end;
?
|
|
|
Post by Kevin on Mar 1, 2009 16:19:41 GMT -5
Do it the same way, just use OnStartZipInfo and OnEndZip.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 1, 2009 16:44:06 GMT -5
Clear! It works! Thank you once more!
|
|
|
Post by Kevin on Mar 1, 2009 16:45:58 GMT -5
Excellent!!!
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 5, 2009 17:51:13 GMT -5
Sorry, I have to countinue The way to count progress you prompted to me, does not take the SIZE of ALL files, it takes Number of files, so sometimes I have to backup a lot of small files and 1 much more biggest, and i get progress 99% and "hanging up" of application :-( So I need way to count how many data I should zip, and show progress relative to % processed data
|
|
|
Post by Kevin on Mar 5, 2009 18:05:32 GMT -5
Notice...
- OnStartZipInfo has TotalBytes. - OnEndZip has UncompressedSize. - OnStartUnZipInfo has TotalBytes. - OnEndUnZip has Index which allows you to get VCLZip.CompressedSize[Index]
use these instead of NumFiles.
|
|
erazer
Junior Member
Posts: 61
|
Post by erazer on Mar 5, 2009 18:14:19 GMT -5
Sorry, how can I convert TotalBytes: Comp to Integer ?
|
|
|
Post by Kevin on Mar 5, 2009 19:39:11 GMT -5
Well... Round(TotalBytes) comes to mind. There may be other ways too.
|
|