View Full Version : Open a file and retrive the path and write it to a text file
Autoplayit07
11-27-2007, 10:22 AM
Hello.
how can i open a file and get the path to this file.
I have a button witch i would like the user to push and select a file with specific exstension. and ones the file is open i want the program to get the path and write this path to a text file witch is in the autoplay source folder "document".
Autoplayit07
11-27-2007, 12:56 PM
I manage to get the first part right.
but i need a little help with the rest.
this is what i got so far,
result = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "txt", false, false);
current_dir = Folder.GetCurrent(1);
TextFile.WriteFromString("C:\\myfile.txt", "1)"..current_dir, true);
i get this to write the path to the file the user selects,but i need it to write the file name the user selects aswell.
lets say the user selects a file like this on drive C:\test Folder\test.dat
i need the script to write to the text file not only the path like this C:\test Folder
but like this C:\test Folder\test.dat
and allso append this ") after the file name and before the path. like this ("C:\test Folder\test.dat") is that possible .
cause i only get errors when i try to append this ("") around the path.
thank you for any help:)
Dermot
11-27-2007, 01:23 PM
Try this
result = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "txt", false, false);
if result ~= "CANCEL" then
TextFile.WriteFromString("C:\\myfile.txt", "("..result[1]..")", true);
end
Autoplayit07
11-27-2007, 01:43 PM
Try this
result = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "txt", false, false);
if result ~= "CANCEL" then
TextFile.WriteFromString("C:\\myfile.txt", "("..result[1]..")", true);
end
Hey Dermot, thats almost perfect, just one more this i cant get sorted out, your code works perfect, but i need it to include this too " like this ("the path and file name"). i dont know how to place these " without getting an error.
Lorne
11-27-2007, 01:44 PM
To include quotation marks in a string, you need to escape them, like this: \"
:)
Autoplayit07
11-27-2007, 01:50 PM
To include quotation marks in a string, you need to escape them, like this: \"
:)
hey thanks Lorne that worked. :)
thank you booth, for helping out :yes
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.