Dir Exists on SDCard

cnicolapc

Active Member
Licensed User
Longtime User
hi,
How can I do to check if a DIR Exist on sd card and avoid the error if I try to open a file?
Thank You in advance
I tried so but I always return false
B4X:
If File.Exists(File.DirDefaultExternal& "/memoBackup/","*.*")=True Then
      Msgbox("True","")
      Else
      Msgbox("False","")
      End If

Nicola
 
Last edited:

cnicolapc

Active Member
Licensed User
Longtime User
hi,

I tried so, but if DIR memoBackup Exist on SD return FALSE
and If I DELETE memoBackup DIR on SD I still return FALSE.
What can it be? yet the path is right.

B4X:
MyPath = File.DirRootExternal & "/memoBackup/"
If File.Exists(MyPath, "") = False Then
        Msgbox("False","")
      Else
      Msgbox("True","")
      End If

Thank Again
Nicola
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Dir Info

The code you have listed is correct. Android is case sensitive and you need to make sure that the directory when you created it is memoBackup and not memobackup. If you use the code I listed you must have the "/" at the beggining of the path/filename after the File.DirRootExternal, however, the "/" is not needed at the end of the path. I ran the code below and it works fine:

B4X:
File.MakeDir(File.DirRootExternal, "memoBackup")
   
MyPath = File.DirRootExternal & "/memoBackup/"
   
If File.Exists(MyPath, "") = False Then
        Msgbox("False","")
Else
   Msgbox("True","")
End If

Margret
 
Last edited:
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
hi,
Sorry guys, I'm an idiot
I made ​​a copy and paste the example of Margret and I have not checked
my DIR is in file.DirDefaultExternal and not in file.DirRootExternal.
Forgive me if I wasted your time, now it all works, thanks.
Nicola
 
Upvote 0
Top