FileDialog DirAssets problem

mebcs

Member
Licensed User
Longtime User
I have included several files in the project Files tab and can see them with:
B4X:
Log(File.ListFiles(File.DirAssets ))

But If I try to use the dialog it gives me an error indicating the directory does not exist.
B4X:
Dim fd As FileDialog
Dim ret As Int
fd.FastScroll = True
fd.FilePath = File.DirAssets 
fd.FileFilter = ".*" 
ret=fd.Show ("Select File to Load","","","",Null )


Yet, I can open the file if I hardcode it as follows:
B4X:
Dim In As InputStream
Dim FileToProcess As String 
FileToProcess=File.DirAssets & "/" & 'baseconfiiguration.xml"
If File.Exists (File.DirAssets, 'baseconfiiguration.xml") Then
   In = File.OpenInput(File.DirAssets, 'baseconfiiguration.xml")
             'do something with the file
Else
   ToastMessageShow(FileToProcess & " DOES NOT EXIST", True)
End If

What am I doing wrong?
 

NJDude

Expert
Licensed User
Longtime User
You will have to get a list of all the files, like this:
B4X:
Dim AllFiles As List

AllFiles.Initialize

AllFiles.AddAll(File.ListFiles(File.DirAssets))
            
Msgbox("Files found = " & AllFiles.Size, "")
            
For I = 0 To AllFiles.Size -1
            
    Msgbox(AllFiles.Get(I), "")
            
Next

Then you can manipulate the results, search for the file you need, etc.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…