get the drive, path, filename, extension from a given string like this:
"c:\windows\system\blahblah.txt"
im talking about ready VB functions, if there are any....
Printable View
get the drive, path, filename, extension from a given string like this:
"c:\windows\system\blahblah.txt"
im talking about ready VB functions, if there are any....
This isn't the answer you want - no easy-to-use builtins
are available in VB
Goto VBNET. And search for 'shell path routines'
It shows api calls for parsing paths, filenames, etc.
Click here
I don't know of any single commands to give you this info, but this is what I normally use:
Code:Directory = "C:\Windows\System\Test\File.exe"
FilePath = Left(Directory, InStrRev(Directory, "\"))
FileName = Right(Directory, Len(Directory) - InStrRev(Directory, "\"))
FileExtension = Right(Directory, Len(Directory) - InStrRev(Directory, "."))
DriveLetter = Left(Directory, 1)
Try this:
Code:Private Sub Form_Load()
Dim sFilePath As String
Dim sDrive As String
Dim sPath As String
Dim sFile As String
Dim sExtension As String
Me.AutoRedraw = True
sFilePath = "c:\windows\system\blahblah.txt"
sDrive = Left$(sFilePath, 3)
sPath = Mid$(sFilePath, 3, InStrRev(sFilePath, "\") - 2)
sFile = Mid$(sFilePath, InStrRev(sFilePath, "\") + 1)
sExtension = Mid$(sFilePath, InStrRev(sFilePath, "\") + InStr(Mid$(sFilePath, InStrRev(sFilePath, "\") + 1), "."))
Print sDrive
Print sPath
Print sFile
Print sExtension
End Sub