Reputation: 2197
File.Delete(path);
I am using function above.
I have multiple file.
How can i delete multiple file without calling File.Delete()
function multiple time?
Upvotes: 1
Views: 631
Reputation: 84734
Outside of deleting the entire directory, you have no choice but to call File.Delete
multiple times. As per the documentation, the path argument is:
The name of the file to be deleted. Wildcard characters are not supported
Upvotes: 1
Reputation: 82096
There are no solutions that will allow you to delete multiple files using File.Delete
with a single call. If your worried about performance you could put your code into a background thread.
Upvotes: 1
Reputation: 807
The files that you have multiples of must have different extensions, and in the path you have to specify which one you would like to delete, so if the files that are constantly in multiples are the same few extensions(.exe etc) then run a loop that gets the filename and adds on each extension to delete them.
Upvotes: 0