Getting filename path and extension
I was wondering if anyone knows of a class or function that will spilt a filepath like "C:\TEMP\myfile.doc" into the 3 parts
path = C:\TEMP\
File = myfile
extension = doc
???
I know if can be done with the FSO but it's a waste to include that just for this. And I want to handle files with no extension or with 2 "."'s in the name so using string functions like instr is not reliable.
Jean-Guy
Re: Getting filename path and extension
You can use split function
dim line() as string
dim iIndex as integer
line=split(path,"\")
This will split the line at the backslash and put each element in the line() array.
then to find the path ( without file name)
For iIndex = LBound(line) To UBound(line)-1'except the last element which is the file name
PATH = path & line(iIndex) & "\"
Next
the same way you can find the file name
FileName=split(line(UBound(line)),".")
something like that . I did not try it but that will give you an idea
Iouri Boutchkine
[email protected]