File.Move etc

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

    File.Move etc

    Have a small dilemma. I'm doing a File.Move (actually allowing the user to save a file to a different location) with this code -

    function savefile()
    file = Dialog.FileBrowse(false, "Save your file", _DesktopFolder, "All Files (*.*)|*.*|", "*.exe", "exe", false, true);
    if (file[1] ~= "CANCEL") then
    File.Move(_SourceDrive.."\\originalfile.exe", file[1], false, false, true, true, nil);
    else
    cancel = Dialog.Message("Cancelled?", "Are you sure you want to cancel?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1);
    if (cancel == IDYES) then
    return
    else
    savefile();
    end
    end
    end

    The function and all works perfect, except if they saved a file previously as "myfile.exe" and they decide to name the file "myfile.exe" again, it doesn't ask to over-write. Is there a way I can prompt the user "are you sure you want to overwrite this file"? Currently, it just overwrites the file with no prompts.
    Regards,

    -Ron

    Music | Video | Pictures
  • TJ_Tigger
    Indigo Rose Customer
    • Sep 2002
    • 3159

    #2
    You could use the Overwrite option in the File.Move function to prevent the file from being over written.

    I don't know how exactly, but you might also add a File.DoesExist action to your code to check and see if the file name already exists and if no the write the file, if yes then prompt the user.
    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

      #3
      Originally posted by TJ_Tigger
      You could use the Overwrite option in the File.Move function to prevent the file from being over written.
      Nah, doesn't work. If you look at the File.Move action and highlight overwrite option, it gives you - Whether to overwrite any files in the destination folder if they have the same name as the files being moved

      This doesn't help, it will still overwrite an "existing" file of any name - silently. I somehow need to take what they type in the dialog and compare it to the file being overwritten (if the case), but how in the heck can I do that?
      Regards,

      -Ron

      Music | Video | Pictures

      Comment

      • TJ_Tigger
        Indigo Rose Customer
        • Sep 2002
        • 3159

        #4
        Code:
        fexist = File.DoesExist(file[1]);
        if (fexist) then
             qresult = Dialog.Message("Warning","You are about to overwrite an existing file. \r\n Do you want to continue?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON2); 
             if (qresult == IDYES) then
                  File.Move(_SourceDrive.."\\originalfile.exe", file[1], false, false, true, true, nil); 
             else
                  --allow them to enter a new name for the file here
             end
        end
        What if you do something like to following. Fun a quick File.DoesExist to see if the file they want to use already exists and if it does prompt them to overwrite or not. Or you could pull the windows trick and add "Copy X" to the front of the file name before you save it.

        I have not tested the code in AMS just worked with it here so it may need some massaging.

        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

          #5
          That worked!! Now I need to somehow insert my cancel dialog

          I'm getting lost with all the if's and else's and ends. I think I just need a break - time for coffee :o

          Thanks again Tigg! If you ever need any help <long pause> .......um, I won't be able to do it......maybe someday!
          Regards,

          -Ron

          Music | Video | Pictures

          Comment

          Working...
          X