Android Question File.MakeDir doesn´t seems to work properly

cds-soft

Member
Licensed User
Sorry for this stupid question, but i don't know why this code always shows the folder doesn't exists.

B4X:
Dim s As String
s = "todo"
If File.Exists(File.DirInternal & s & "/", "") = False Then
    ' Creamos la carpeta de descarga
    File.MakeDir(File.DirInternal, s)
    ' Validamos
    If File.Exists(File.DirInternal & s & "/", "") = False Then
        Msgbox("Error", "")
        Return
    End If
End If
Edit because I solved it :)

Well this is the info for File.MakeDir (Info)
MakeDir (Parent AsString, Dir AsString)

Creates the given folder (creates all folders as needed).
Example:
File.MakeDir(File.DirInternal, "music/90")
Well, this is not correct.

The correct command is...
B4X:
File.MakeDir(File.DirInternal, "/music")
And if you want to check if this directory exist, you can do
B4X:
If File.Exists(File.DirInternal "/music", "") = True Then
OR
B4X:
If File.Exists(File.DirInternal "/music/", "") = True Then
Both are accepted.

I hope this will be usefull for B4A "newies" like me. And hope this info should be fixed.

Thanks for your help and sorry for my english:(
 
Last edited:

cds-soft

Member
Licensed User
I think you should be using IsDirectory
I think "IsDirectory" is to check if it's a directory or not.

If you want to check a directory exist you have to do File.Exist with file name empty
This return true.
B4X:
File.Exists("/mnt/sdcard/Download/", "")
Thanks NJDude.
 
Top