'Returns external/physical SD Card directory
Public Sub getSDCardPath() As String
Dim LF As String = Chr(10) 'line feed' character
Dim CR As String = Chr(13) 'carriage return' character
Dim iMount, iLF, iSlash, iAuto As Int
Dim fstab As String = File.ReadString("/system/etc/", "vold.fstab")
Dim Mount As String
fstab = fstab.Replace(TAB, " ") 'replace tab characters
fstab = fstab.Replace(CR, LF) 'normalize linefeeds
fstab = fstab.Replace(":", " ") 'replace colon characters (Motorola-case)
Do While True
'get next line with mount point:
iMount = fstab.IndexOf2(LF & "dev_mount ", iLF) + 1
If iMount < 1 Then Exit
iLF = fstab.IndexOf2(LF, iMount)
If iLF < 0 Then Exit
Mount = fstab.SubString2(iMount, iLF)
'get mount path:
iSlash = Mount.IndexOf("/")
If iSlash < 0 Then Continue
iAuto = Mount.IndexOf2("auto", iSlash)
If iAuto < 0 Then Continue
Mount = Mount.SubString2(iSlash, iAuto).Trim
'return this one, if new:
If Mount <> File.DirRootExternal Then Return Mount
Loop
Return File.DirRootExternal
End Sub