Click to See Complete Forum and Search --> : Getting filename path and extension


Jean-Guy2000
April 20th, 2001, 12:41 PM
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

Iouri
April 20th, 2001, 01:01 PM
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
iouri@hotsheet.com