User defined file copying?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • NoNickWorking
    Forum Member
    • Dec 2007
    • 5

    User defined file copying?

    Hi,
    I'm new to AMS and right on the first project I'm running into some problems:

    All I want is that when I click a button, a popup comes up to ask the user where he wants to copy the file.

    I've used the forum search ("file copy" and "file copy destination") but couldn't find the answer. :o

    Is there an easy way to do this?

    Thanks in advance!

    Kind regards

    P.S.: Sorry about the nick. I've tried my usual nick (Markstar) but that didnt' work. Then tried some others but all were rejected (including a weired one). This was just a last test to see if I'd get it to work at all.
  • Mina
    Forum Member
    • Oct 2005
    • 630

    #2
    Try this

    Code:
    vA = (_SourceFolder.."\\myfile.exe") -- (the file you want to copy)
    vB = Dialog.FolderBrowse("Where to copy the file to", _Desktop);
    File.Copy(vA, vB, true, true, false, true, nil);

    Comment

    • NoNickWorking
      Forum Member
      • Dec 2007
      • 5

      #3
      Thank you so much!!!!!

      It worked after I changed _Desktop to "_Desktop" (it required a string).

      This works EXACTLY how I wanted it to! :yes
      Last edited by NoNickWorking; 12-18-2007, 05:00 PM.

      Comment

      • NoNickWorking
        Forum Member
        • Dec 2007
        • 5

        #4
        Argh, now I want to do the same with File.Install (because it can create a backup), but somehow this doesn't work. Here is the code:
        Code:
        vA = ("\\test.exe")
        vB = Dialog.FolderBrowse("Where to install the file to", "_Desktop");
        result = File.Install(vA, vB, FILE_INSTALL_ALWAYS, true, false, nil, nil);
        if (result == true) then
        	Dialog.Message("Notice", "File installed succesfully to "..vB, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        else
        	Dialog.Message("Notice", "File not installed", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        end
        It appears there is something wrong with the vB variable because if I replace vB with "D:\\dest\test.exe", it does work. :o

        I considered it being a syntax error (after all, the string from Dialog.FolderBrowse looks like "D:\dest" but then why does it work in File.Copy?

        Comment

        • Mina
          Forum Member
          • Oct 2005
          • 630

          #5
          I think something's missing in

          Code:
          vA = ("\\test.exe")
          Perhaps you mean:

          Code:
          vA = (_SourceFolder.."\\test.exe")

          Comment

          • NoNickWorking
            Forum Member
            • Dec 2007
            • 5

            #6
            Well, it does work without the _Sourcefolder (but yes, it is surely better to have it so it also works when the drive changes).

            So the problem is still there.

            Comment

            • NoNickWorking
              Forum Member
              • Dec 2007
              • 5

              #7
              Hmm, I've been thinking about this quite a lot. It should be possible to write a little procedure to create a backup first and then copy the file. It would be a lot more complicated than simply using File.Install.

              I guess I'll have to do that if File.Install really doesn't work (which I find quite odd).

              Anyways, thanks for the help so far (though I still hope someone will see what is the cause of this).

              Comment

              Working...
              X