Deleting Files

Frogger

Member
Licensed User
Longtime User
I've just bought B4PPC. Sorry about having to ask this - I could program in Basic ok on my Amstrad in the 80s but I'm having trouble getting to grips with B4PPC :(

I'm trying to delete a directory of files in the internal storage on my phone, but I have no idea what the notation of the file structure is and I can't find anything in the help files etc. I've tried something like this:

B4X:
FileDel ("\A Folder\Another Folder\TestFolder\*.*")

But there's always an error :(

What on earth am I doing wrong?
 

specci48

Well-Known Member
Licensed User
Longtime User
Hello Frogger,

as far as I know FileDel supports no wildcards, so you can only delete a single file with it.

A possible solution is to read all filenames into an ArrayList and then delete every single file with a loop:
B4X:
        AddArrayList("alFiles")
   FileSearch (alFiles, "\A Folder\Another Folder\TestFolder")
   For i = 0 To alFiles.count - 1
      FileDel(alFiles.item(i))
   Next


specci48
 

nick2210

Member
fileDel

Hello.
I have tried this way
fileDel("\my documents"&"\another folder"&"\testfolder")
It deletes the testfolder

......if I get your question correctly
 

Frogger

Member
Licensed User
Longtime User
Hello Frogger,

as far as I know FileDel supports no wildcards, so you can only delete a single file with it.

A possible solution is to read all filenames into an ArrayList and then delete every single file with a loop:
B4X:
        AddArrayList("alFiles")
   FileSearch (alFiles, "\A Folder\Another Folder\TestFolder")
   For i = 0 To alFiles.count - 1
      FileDel(alFiles.item(i))
   Next

Ah, I didn't know that it didn't support wildcards. Anyway, the above works, thank you very much for your help! :)
 

Frogger

Member
Licensed User
Longtime User
Hello.
I have tried this way
fileDel("\my documents"&"\another folder"&"\testfolder")
It deletes the testfolder

......if I get your question correctly

Thank you for the reply. I'm trying to delete all files in a folder, not the actual folder itself.
 
Top