DirDelete using wildcard

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
lmangcahan
Posts: 25
Joined: September 7th, 2021, 3:45 am

DirDelete using wildcard

Post 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.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: DirDelete using wildcard

Post 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.
Post Reply