protected int clearCacheFolder(Java.IO.File dir) { int deletedFiles = 0; if (dir!= null && dir.IsDirectory) { try { foreach(var child in dir.ListFiles() ){ //first delete subdirectories recursively if (child.IsDirectory) { deletedFiles += clearCacheFolder(child); } //then delete the files and subdirectories in this dir //only empty directories can be deleted, so subdirs have been done first if (child.Delete()) { deletedFiles++; } } } catch(Exception e) { } } return deletedFiles; }