Consider the following examples:
"C:\temp\test.txt"
"C:\temp\test\test1\test.txt"
And other full paths... How can I remove the drive from the start of the string. Following on from the above example, I would like to return:
"temp\test.txt"
"temp\test\test1\test.txt"
I realise that I can just use a string search/replace, but is there some official code to do this via a fileInfo object or other such method? I know that the fileinfo returns the directory name, extension etc. Is there a 'drive' part to a fileInfo object? Or should I use another type of object all together?
Currently I am using this code:
If however, the drive has a name, that not is in the standard "C:\, D:\, E:\" format, this code will not work.
"C:\temp\test.txt"
"C:\temp\test\test1\test.txt"
And other full paths... How can I remove the drive from the start of the string. Following on from the above example, I would like to return:
"temp\test.txt"
"temp\test\test1\test.txt"
I realise that I can just use a string search/replace, but is there some official code to do this via a fileInfo object or other such method? I know that the fileinfo returns the directory name, extension etc. Is there a 'drive' part to a fileInfo object? Or should I use another type of object all together?
Currently I am using this code:
Code:
Public Function removeDriveFromFilePath(stringFilePath As String) As String
Dim stringDrivePath As String = Left(stringFilePath, InStr(stringFilePath, "\"))
Return stringFilePath.Replace(stringDrivePath, "")
End Function