PDA

View Full Version : File open And Copy to destination


ianhull
08-24-2005, 08:56 AM
Hi Guys,

I am trying to open a file and copy it to a specific folder.

Here is what I have

image1 = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "Image Files (*.jpg*)|*.jpg*|", "", "jpg", false, false);
File.Copy(("image1"), "C:\\mydir\\", true, true, false, true, nil);

Any ideas on th correct syntax.

Thanks

Worm
08-24-2005, 09:30 AM
image1 = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "Image Files (*.jpg*)|*.jpg*|", "", "jpg", false, false);
if image1[1] ~= "CANCEL" then
tblFileInfo = String.SplitPath(image1[1])
File.Copy(image1[1], "C:\\mydir\\"..tblFileInfo.Filename..tblFileInfo.Extension, true, true, false, true, nil);
end

ianhull
08-24-2005, 09:59 AM
Thanks for that Worm but the image does not seem to be copied.
I see you have created a string tblFileInfo what does this mean?
Do I need a table on my page?

thanks

Worm
08-24-2005, 10:12 AM
It works here. The only thing is that the folder you are copying the file too, must already exist.

ianhull
08-24-2005, 10:15 AM
Thanks Worm,

I did not realise it had to exist lol.

It works great now.

Thank you.

ianhull
08-24-2005, 10:18 AM
Worm do you know how I could store the image name in a string so that I can write it to a text file?

Thanks.

TJ_Tigger
08-24-2005, 10:33 AM
Worm do you know how I could store the image name in a string so that I can write it to a text file?

Thanks.

If you just want the name you can use the String.Split to split the path into parts and then use the Filename or Filename and extension as your string.


image1 = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "Image Files (*.jpg*)|*.jpg*|", "", "jpg", false, false);
if image1[1] ~= "CANCEL" then
tblFileInfo = String.SplitPath(image1[1])
strFilename = tblFileInfo.Filename
--or if you want the extension as well
--strFilename = tblFileInfo.Filename.. tblFileInfo.Extension
File.Copy(image1[1], "C:\\mydir\\"..tblFileInfo.Filename..tblFileInfo.Extension, true, true, false, true, nil);
end


Tigg

ianhull
08-24-2005, 11:39 AM
Thanks TJ Tigger.

Very much appreciated. :yes

I will have to start remembering all this instead of asking you guys all the time.

Thanks again.