Chronovore
May 2nd, 2001, 01:47 PM
I have a string that contains a full path to a file. I want to break it up so that I have 3 strings that have the drive, the path, and the file. The drive string was easy to get with Left(), but now I run into the problem of the path and file name. The path is variable.
shree
May 2nd, 2001, 01:57 PM
Use InStr to find the first occurrence of \
Use InstrRev to find the last occurrence of \
Knowing these two positions, you can
Use Left$ to extract the drive
Use Mid$ to extract the portion between these two positions, it will be your path
Use Right$ to extract the filename
Kdev
May 2nd, 2001, 02:04 PM
dim sFile as string, sDrive as string, sPath as string, sFileName as string
sFile = "C:\Program Files\Project 1\Project1.exe"
sDrive = Left(sFile, 1)
sPath = Mid(sFile, Instr(sFile, "\"), InstrRev(sFile, "\") - Instr(sFile, "\") + 1)
sFileName = Right(sFile, Len(sFileName) - InstrRev(sFile, "\"))
A bit crude but I like shortcuts :p
-K