|
-
May 9th, 2001, 02:54 PM
#1
Thread Starter
Lively Member
How can i....
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....
-
May 9th, 2001, 03:15 PM
#2
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
-
May 9th, 2001, 03:26 PM
#3
Hyperactive Member
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)
-
May 9th, 2001, 03:42 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|