this function will extract the contents of a zip file, it will frist ask the user for the location of the zip archive then will ask for the location of the folder to exrtract to
there is error checking in the code so if any error occurs then the user is informed
this script is stand alone ie: it dosent need any objects to function
copy n paste this code into your project or download the lua attached to this post
PHP Code:function OpenZip()
-- get the location of the zip archive
GetFile = Dialog.FileBrowse(true, "Locate Zip File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
-- check that cancel wasent clicked, if it was exit the script
if GetFile[1] == "CANCEL" then
Application.ExitScript();
else
-- get the folder to extract to
GetFolder = Dialog.FolderBrowse("Please select a folder to extract to:", _DesktopFolder);
-- check that cancel wasent clicked, if it was exit the script
if GetFolder == "CANCEL" then
Application.ExitScript();
else
-- extract the archive
Zip.Extract(GetFile[1], {"*.*"}, GetFolder, true, true, "", ZIP_OVERWRITE_NEVER, nil);
-- check that there was no error, if there was inform the user
err = Application.GetLastError();
if (err ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end
end
end
end
-- call the function
OpenZip();

Reply With Quote