B4J Question file chooser

moore_it

Well-Known Member
Licensed User
Longtime User
Hi all,

i need to get the directory and the filename separated from filechooser class, it's possible ?

Thanks in advice
Toni
 

eurojam

Well-Known Member
Licensed User
Longtime User
look here...it is not my code, somebody else posted that code before...
B4X:
' Returns the filename from a fullpath
Sub getFileName(path As String) As String
  ' Define the JavaObject
  Dim fileO As JavaObject
  ' Get the fileio class
  fileO.InitializeNewInstance("java.io.File", Array As Object(path))
  ' Getthe filename
  Return fileO.RunMethod("getName", Null)
End Sub

' Returns the filepath from a fullpath
Sub getFilePath(path As String) As String
  ' Define the JavaObject
  Dim fileO As JavaObject
  ' Get the fileio class
  fileO.InitializeNewInstance("java.io.File", Array As Object(path))
  ' Getthe filename and path
  Dim n As String = fileO.RunMethod("getName", Null)
  Dim p As String = fileO.RunMethod("getPath", Null)
  p = p.Replace(n, "")
  Return p
End Sub
 
Upvote 0
Top