A little help w/zipAdd please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • rhosk
    Indigo Rose Customer
    • Aug 2003
    • 1698

    A little help w/zipAdd please

    Need a little push here again :

    I have a save dialog where the user saves an executable file where they want. Let's say they save it as "C:\folder\myfile.exe"
    I have this populating a list box with the full path, np.

    What I want it to do is zip this particular file and have it end up as "C:\folder\myfile.zip"

    I'm almost there, I'm just lost when it comes to the ZipAdd action. Where -

    contain = ListBox.GetItemText("ListBox2", 1);
    Zip.Add("C:\\Myzip.Zip", contain, false, "", 5, nil);

    How do I tell ZipAdd to save it as the same file name? So it ends up in the same folder as "myfile.exe"? I just want to make it easy for the user to let them know that the file is zipped "in the same folder" that they saved their executable.
    Regards,

    -Ron

    Music | Video | Pictures
  • rhosk
    Indigo Rose Customer
    • Aug 2003
    • 1698

    #2
    Anyone?
    Regards,

    -Ron

    Music | Video | Pictures

    Comment

    • TJ_Tigger
      Indigo Rose Customer
      • Sep 2002
      • 3159

      #3
      Ron,

      If I remember from an earlier post of yours you have the name of the file saved as a variable and the path as a variable as well. You should be able to use those variables to define your zip file name and path. Is this what you are looking for is how to use that information to create the zip file?

      Tigg
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment

      • rhosk
        Indigo Rose Customer
        • Aug 2003
        • 1698

        #4
        Tigg, I got the file path (variable)....how do I name that Zip "file" the same as the saved file? I hope it makes sense. The variable for the path is easy, but I guess I need to strip the string to name the zip file the same (with the .zip ext). Can you give me a hint? Thanks!
        Regards,

        -Ron

        Music | Video | Pictures

        Comment

        • TJ_Tigger
          Indigo Rose Customer
          • Sep 2002
          • 3159

          #5
          You can use the String commands to strip the filename from the extension. You could strip the exe or the .exe or use String.SplitPath to split the information from the filename into several parts that are then contained in a table. You could then use that to save it to the appropriate zip file.

          --define the folder and file variables
          pathvariable = "C:\\folder\\";
          filevariable = "myfile.exe";
          --create a full file and path structure in a single variable
          fullpath = pathvariable..filevariable;
          --split the file path into a table containing the variables
          splitfiletable = String.SplitPath(fullpath);
          --add the file to a table so it can be added to the zip file
          filetable = {fullpath};
          --ad the contents of the table to the zip file
          Zip.Add(pathvariable..splitfiletable.Filename..".z ip", filetable, false, "", 5, nil);

          I haven't tested it but see if that will work for ya.
          TJ-Tigger
          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
          "Draco dormiens nunquam titillandus."
          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

          Comment

          • Crash_Davenport

            #6
            Ron,

            This might help if I'm understanding this right.

            saveFile = Dialog.FileBrowse(false, "Save As", "c:\\", "zip File (*.zip)|*.zip|", "your_file", "zip", false, true);
            getFileName = String.SplitPath(saveFile[1]);
            fileName = (getFileName.Drive..getFileName.Folder..getFileNam e.Filename..getFileName.Extension);

            Comment

            • rhosk
              Indigo Rose Customer
              • Aug 2003
              • 1698

              #7
              OK guys, thanks for the help so far - I'm || this close Here's what I have and the result

              contain = ListBox.GetItemText("ListBox2", 1);
              --define the folder variable
              pathvariable = contain;
              --create a full file and path structure in a single variable
              fullpath = pathvariable;
              --split the file path into a table containing the variables
              splitfiletable = String.SplitPath(fullpath);
              --add the file to a table so it can be added to the zip file
              filetable = {fullpath};
              --ad the contents of the table to the zip file
              Zip.Add(pathvariable..splitfiletable.Filename..".z ip", filetable, false, "", 5, nil);

              This almost works perfect except the resulting file name is

              "myfile.exe.myfile.zip" (which still does work mind you, but looks funny). Doesn't contain any folder paths or anything, which is exactly what I wanted!

              I've tried [..splitfiletable..".zip"] leaving out [Filename..] but this doesn't work.

              So, one last thing, how do I end up with just "myfile.zip" and I'm DONE?
              Regards,

              -Ron

              Music | Video | Pictures

              Comment

              • TJ_Tigger
                Indigo Rose Customer
                • Sep 2002
                • 3159

                #8
                Originally posted by rhosk
                OK guys, thanks for the help so far - I'm || this close Here's what I have and the result

                contain = ListBox.GetItemText("ListBox2", 1);
                --define the folder variable
                pathvariable = contain;
                --create a full file and path structure in a single variable
                fullpath = pathvariable;
                --split the file path into a table containing the variables
                splitfiletable = String.SplitPath(fullpath);
                --add the file to a table so it can be added to the zip file
                filetable = {fullpath};
                --ad the contents of the table to the zip file
                Zip.Add(pathvariable..splitfiletable.Filename..".z ip", filetable, false, "", 5, nil);

                This almost works perfect except the resulting file name is

                "myfile.exe.myfile.zip" (which still does work mind you, but looks funny). Doesn't contain any folder paths or anything, which is exactly what I wanted!

                I've tried [..splitfiletable..".zip"] leaving out [Filename..] but this doesn't work.

                So, one last thing, how do I end up with just "myfile.zip" and I'm DONE?
                Ron,

                The splitfiletable is required with the .Filename because it splits the full path and filename into a table with the following entries:

                KEY TYPE DESCRIPTION

                Drive string The drive portion of the path (for example, C.

                Folder string All of the folders within the path (for example, \MyFolder1\MyFolder2\).

                Filename string The filename in the path (for example, "myfile").

                Extension string The file extension in the path (for example, ".exe").


                What appears to be happening is when you get the item from the list box this contains the filename of the file originally saved file. You end up setting pathvariable equal to contain and then fullpath equal to pathvariable. Both of those line should not be required for your project but I included them in the code to show what was being fed into the String.SplitPath and Zip.Add actions. All you would need to work with is the contain variable which I assume contains the path and filename of the original file you want to zip. Try this

                contain = ListBox.GetItemText("ListBox2", 1);

                --split the file path into a table containing the variables
                splitfiletable = String.SplitPath(contain);

                --add the file to a table so it can be added to the zip file
                filetable = {contain};

                --ad the contents of the table to the zip file
                Zip.Add(splitfiletable.Drive..splitfiletable.Folde r..splitfiletable.Filename..".zip", filetable, false, "", 5, nil);

                Tigg
                TJ-Tigger
                "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                "Draco dormiens nunquam titillandus."
                Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                Comment

                • rhosk
                  Indigo Rose Customer
                  • Aug 2003
                  • 1698

                  #9
                  Yes sir, that worked perfect, thanks!! Gotta tell ya, learned a helluvalot in this thread. Just couldn't figure out where the "fileName" was being broken down. Appreciate the detailed walkthru; I'll be able to apply this in many areas.
                  Regards,

                  -Ron

                  Music | Video | Pictures

                  Comment

                  Working...
                  X