PDA

View Full Version : Determining file name


Agent Jones
02-20-2005, 01:42 PM
In my project, I allow the user to browse for one or more files from his computer.

However, the table returns the full path for the file. Example:
file = Dialog.FileBrowse(true, "Select File", _DesktopFolder, "All Files (*.*)|*.*|", "", "unk", true, true);
num = Table.Count(file);

for n=1,num do
StatusDlg.SetMeterPos(n);

nm = String.Right(file[n], fn+1);
StatusDlg.SetStatusText(n.." of "..num);
--do my stuff...
StatusDlg.SetMeterPos(n);
end
I really need the filename only... Example:
pic1.jpg instead of C:\pic1.jpg. Is it possible? Thanks.

Agent Jones
02-20-2005, 01:57 PM
OK forget about it... Found a solution :)

Worm
02-20-2005, 01:57 PM
Look into String.SplitPath

tFileInfo=String.SplitPath("C:\\Pictures\\MyPic.jpg")

tFileInfo.Drive would be "C:\"
tFileInfo.Folder would be "Pictures"
tFileInfo.Filename would be "MyPic"
tFileInfo.Extension would be "jpg"