FileBaseName and FileExtension, found in the jMMTools library are just what I needed.
But, I'd like to know if there are any other slick ways the get the name and extension out of a file?
Dim FullFilePath As String = "C:/users/file.ext"
Dim FileName As String = File.GetName(FullFilePath)
Dim Pos As Int = FileName.LastIndexOf(".")
Dim FileBase As String = FileName.SubString2(0,Pos)
Dim FileExtn As String = FileName.SubString(Pos)
Log(FileBase)
Log(FileExtn)
You shouldn't assume that there is an extension. You need to check that Pos is not -1.
B4X:
Dim FileBase, FileExtn As String
if Post = -1 Then
FileBase = FileName
Else
FileBase = FileName.SubString2(0,Pos)
FileExtn = FileName.SubString(Pos)
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.