PDA

View Full Version : more on zip files...



dulux1309
03-02-2004, 11:54 AM
Hi again,

I am using the code from the .zip demo (the one with the three blue buttons offering options for zipping individual files, folders non-recursively and folders recursively) Here is the rub - I am trying to zip a directory that has other sub directories in it. I would like to zip the root and have all the other folders retain their structure. At the moment, it is simply taking all files within the root and placing them in the root of the zip file. How can i get this to zip the folder and retain the folder structure?

Cheers.

Ted Sullivan
03-02-2004, 12:06 PM
Make sure you're using 5.0.0.4 and read the new documentation. Unfortunately, the syntax changed just a little bit and you'll need to adjust the sub-folder setttings.

rhosk
03-02-2004, 12:21 PM
http://www.indigorose.com/forums/showthread.php?s=&threadid=6746

:)

dulux1309
03-02-2004, 12:30 PM
Thanks all -

I have read the updated docs and followed the kindly posted link, and now the following is happening -

my zip file is created a treat, complete with the sub folders, but they are empty. Their contents are still being added to the root of the zip file and not staying within the subfolders!

below is the code, for clarity.

--------------------------------------------
-- Get the user to specify where to create the zip file
tFiles = Dialog.FileBrowse(false, "Save As", "", "Zip Archives (*.zip)|*.zip|", "", "zip", false, false);
-- Ensure the user did not press 'cancel'
if tFiles[1] ~= 'CANCEL' then
-- copy file path to a string
sZipFile = tFiles[1];
-- Get the user to select a folder containing files to add to the zip file
sLocation = Dialog.FolderBrowse("Directory Location", "Please select a directory containing the files you wish to add:");
-- Ensure the user did not press 'cancel'
if sLocation ~= 'CANCEL' then
-- Show the status dialog
StatusDlg.Show(0, false);
-- Find all files in the selected directory (recursive)
tFiles = File.Find(sLocation, "*.*", true, false, nil);
-- Hide the status dialog
StatusDlg.Hide();
-- Ensure there are files to add
if tFiles then
-- Show the status dialog
StatusDlg.Show(0, false);
-- Add the found files to the zip file
Zip.Add(sZipFile, tFiles, true,"", 5, nil, true);
-- Hide the status dialog
StatusDlg.Hide();
end
end
end
-------------------------------------------

thanks

dulux1309
03-02-2004, 01:43 PM
I have read the examples and tried everything I can think of to make this work properly - I am still getting everything removed from the subfolders and placed in the root, even though the subfolders themselves are recreated in the .zip.

The line below seems to be correct, but I am pulling my hair out here - maybe time for a hat. Has anyone else seen this problem?

---------------------------------------

Zip.Add(sZipFile, tFiles, true,"", 5, nil, true);

rhosk
03-05-2004, 02:19 PM
I think IR is looking into this (guessing). They gave me an awesome solution via the link I provided, but you're right, it seems that that script "should" work and it doesn't. It needs a bit of clarification when using variables.

dulux1309
03-05-2004, 04:59 PM
Thanks for the support - I have a ticket running and the guys at IR have been great so far. I need to respond to them, which I will do tomorrow, and then hopefully things will be a bit clearer...