I have a small problem trying to pre-think what a user may do wrong.
Part of the program looks for a file in external memory provided by the user. Despite writing instructions that the file be all lower case it is inevitable that an upper case character will be used at some time.
Part of the code is shown below, how do I handle a file named "ImpSiteList.CSV" transparent to the user?
Regards Roger
NOTE: Table created in the designer.
B4X:
If File.Exists(File.DirRootExternal&"/ABT/", "impsitelist.csv") = False Then
CustomToastMsg.Show("File 'impsitelist.csv' not found",1000,Gravity.TOP,0,25%y)
Else
Private su As StringUtils
Private Table As List
Table = su.LoadCSV(File.DirRootExternal&"/ABT/", "impsitelist.csv",",")
End If
I would try getting a list of actual filenames using File.ListFiles, and then do a case-insensitive search of the list to get the correctly-cased filename.
I suspect the File.IsDirectory or File.Exists function might get a workout in the process ;-)
I would try getting a list of actual filenames using File.ListFiles, and then do a case-insensitive search of the list to get the correctly-cased filename.
I suspect the File.IsDirectory or File.Exists function might get a workout in the process ;-)
Another possibility is to copy the File.ListFiles non-directories into a ListView or similar, so that the user can only choose existing files, correctly cased to boot.
Another possibility is to copy the File.ListFiles non-directories into a ListView or similar, so that the user can only choose existing files, correctly cased to boot.
I think I need to clarify the process.
The user creates t CSV file, probably from an Excel spreadsheet on a PC. This file needs to be named "impsitelist.csv" and manually loaded into a specific e ternal folder on the Android device.
The user, from the app, can import the file into the apps SQL database with the click of a button. The user does not need to select the file, the file name needs to be of the correct format.
If the app can cope with uppercase letters, that would take confusion away from some users.