C# – Delete all files in a directory
Use Directory.EnumerateFiles() to get a directory’s files and then delete them with File.Delete() in a loop: This deletes the root directory’s files without deleting the directory itself. I’ll show more examples. Delete all files with a specific extension Use Directory.EnumerateFiles’ searchPattern pattern to get files with a specific extension. Here’s an example of deleting all … Read more