Selecting and deleting a file randomly from a directory
in
Programming Questions
•
5 months ago
I'm having some problems understanding how to randomly delete a file from a folder, I can use the delete function to remove a specific file, however could use some pointers on how to choose from all files in the directory.
The files are also generated constantly, so setting a random choice within a range of numbered file titles will not work.
Yeah any ideas are much appreciated
Cheers
Sam
also here's the part of the code i'm currently working with.
void setup() {
String fileName = dataPath("delete.gif");
File f = new File(fileName);
if (f.exists()) {
f.delete();
}
}
1