How To Split A FolderFileName String

rtesluk

Member
Licensed User
Longtime User
Oct 31 2011
01:45 Hours

I am using this code to split the folderpathfilename

e.g. S = /mnt/sdcard/PNG_MP3_Grps/Q_T/Red Checked Parrot7.jpg

B4X:
Sub SplitFF(S As String)
   Dim p As Int 
   For i = 0 To S.Length - 1
      If S.SubString2(i,i + 1) = "/" Then p = i
   Next
   CodeModule.Folder = S.SubString2(0,p)
   CodeModule.FileName = S.SubString(p + 1)
End Sub

CodeModule.Folder = /mnt/sdcard/PNG_MP3_Grps/Q_T
CodeModule.FileName = Red Checked Parrot7.jpg

Is there a better method to perform this function ? Regex ? Other

Ray Tesluk :sign0104:
Port Hope
 

rtesluk

Member
Licensed User
Longtime User
Erel got rid of the loop!!!

Thank you very much Erel

You got rid of the loop and your code is so much more elegant!!!

Ray :sign0098:
 
Upvote 0
Top