macros14
asked on
EASY STRING Q???????????
I have a string array that holds file paths but is nothing more then a file path with a file at the end of it.
\xx\yy\zz\aa.txt
How can I get the name of the text file so everything to the right of the last "\"??? When the file path to the file could be longer or shorter??
\xx\yy\zz\aa.txt
How can I get the name of the text file so everything to the right of the last "\"??? When the file path to the file could be longer or shorter??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another possibility:
Dim fullPathFileName As String = "C:\mydir\myfile.ext"
Dim fileName As String = System.IO.Path.GetFileName (fullPathF ileName)
MsgBox(fileName)
Dim fullPathFileName As String = "C:\mydir\myfile.ext"
Dim fileName As String = System.IO.Path.GetFileName
MsgBox(fileName)
'as above, strPath contains the full filename
dim i as integer = strPath.LastIndexOf("\")
Dim filename as string = ""
If i >= 0 Then
filename = strPath.Substring(i+1)
Else
filename = strPath
End if
msgbox(filename)