Browse for zip to extract.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • soso
    Indigo Rose Customer
    • Jan 2007
    • 73

    Browse for zip to extract.

    Hi been working on the zip extraction and got it to extract a zip in a folder but would like to change this code :

    tFiles = Zip.GetContents("AutoPlay\\Docs\\Test.zip", false);

    --unzip the files
    StatusDlg.Show(0, false);
    Zip.Extract("AutoPlay\\Docs\\Test.zip", tFiles, _TempFolder, false, false, "", ZIP_OVERWRITE_ALWAYS, CallBack)


    So the user can browse for the zip and then it extracts when you press button.


    Can anyone help please


    Cheers soso
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5478

    #2
    This will ask the user for the zip file then ask for the folder to extract to

    PHP Code:
    GetFile Dialog.FileBrowse(true"Locate File"_DesktopFolder"All Files (*.*)|*.*|""""dat"falsefalse);
    GetFolder Dialog.FolderBrowse("Please select a folder:"_DesktopFolder);


    Zip.Extract(GetFile[1], {"*.*"}, GetFoldertruetrue""ZIP_OVERWRITE_NEVERnil); 

    This is real basic stuff, id suggest you read the manual as there are plenty of examples of how to do stuff like this :yes
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    • soso
      Indigo Rose Customer
      • Jan 2007
      • 73

      #3
      Originally posted by RizlaUK View Post
      This will ask the user for the zip file then ask for the folder to extract to

      PHP Code:
      GetFile Dialog.FileBrowse(true"Locate File"_DesktopFolder"All Files (*.*)|*.*|""""dat"falsefalse);
      GetFolder Dialog.FolderBrowse("Please select a folder:"_DesktopFolder);


      Zip.Extract(GetFile[1], {"*.*"}, GetFoldertruetrue""ZIP_OVERWRITE_NEVERnil); 

      This is real basic stuff, id suggest you read the manual as there are plenty of examples of how to do stuff like this :yes

      Thanks for the help and putting me in the right direction, i did read the manaul and sorted out the zip functions but was just having problem with the browse,this may be real basic stuff for yourself and now its real easy for me now but its only easy if you know the answer.

      Many thanks soso

      Comment

      • RizlaUK
        Indigo Rose Customer
        • May 2006
        • 5478

        #4
        but its only easy if you know the answer.
        thats very true and sometimes i forget to take that into account

        you might want to add some error checking it there as well, this is a lil function i came up with for such a task


        put this in globals
        PHP Code:
        function OpenZip()
            
        GetFile Dialog.FileBrowse(true"Locate File"_DesktopFolder"All Files (*.*)|*.*|""""dat"falsefalse);
            if 
        GetFile[1] == "CANCEL" then
            Application
        .ExitScript();
            else    
            
        GetFolder Dialog.FolderBrowse("Please select a folder:"_DesktopFolder);
                if 
        GetFolder == "CANCEL" then
                Application
        .ExitScript();
                else
                
        Zip.Extract(GetFile[1], {"*.*"}, GetFoldertruetrue""ZIP_OVERWRITE_NEVERnil);
                
        err Application.GetLastError();
                    if (
        err ~= 0then
                        Dialog
        .Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
                    
        end
                end
            end
        end 
        and call the function with
        PHP Code:
        OpenZip(); 
        Embrace change in your life, you never know, it could all work out for the best

        Comment

        • bwlewis
          Forum Member
          • Apr 2008
          • 6

          #5
          how would you go about getting the / a progress dialogue
          when the zip file is extracting........
          please

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5478

            #6
            just add the 2 lines of red code

            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
                   [COLOR="Red"] StatusDlg.Show(MB_ICONNONE, false); [/COLOR]
                    -- 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(); 
                    [COLOR="Red"]StatusDlg.Hide();[/COLOR]
                        if (err ~= 0) then 
                            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); 
                        end 
                    end 
                end 
            end  
            -- call the function 
            OpenZip();
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            • raivenz
              Forum Member
              • Jun 2006
              • 3

              #7
              a cancel button in status.dlg

              and how about adding a cancel or abort button in status.dlg
              while the zip file is extracting?
              StatusDlg.ShowCancelButton(true, "Abort"); <--where should i put this?
              i just wanted to cancel the file extraction.

              thankz in advance

              BR raivenz

              Comment

              Working...
              X