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

cds-soft

Member
Licensed User
Longtime 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)
15.png
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:
Top