Page 1 of 1

DirDelete using wildcard

Posted: September 27th, 2021, 3:08 am
by lmangcahan
Hi CSPro Community,
Does the
dirdelete(pathname(Application) + "Backup*")
still works on android 11?
I'm having trouble deleting folders using the wildcard.
below is my code:

list string dirListing;
dirlist(dirListing, "/storage/emulated/0/Android/tempcspro/TEMP_RESPONDENT*");
do numeric ctr = 1 while ctr <= dirListing.length()
dirdelete(strip(dirListing(ctr)));
enddo;
Hope you can help me improve my code.
Wishing everyone is having a great day.

Re: DirDelete using wildcard

Posted: September 27th, 2021, 8:56 am
by Gregory Martin
If you take a look at the helps, it says: "The dirdelete function deletes an empty directory or group of empty directories."

You will have to delete the individual files in each directory before you delete the directory itself.

You can call dirlist with the recursive option, delete all files, and then loop through again and delete the directories.