Reputation: 2499
How do you remove files from a folder using ASP.Net with C# ?
Upvotes: 2
Views: 4133
Reputation: 29963
Same as the above answers, but lambda-fied, if that's your thing...
Array.ForEach(Directory.GetFiles(path), File.Delete);
Upvotes: 3
Reputation: 9617
foreach (var file in Directory.GetFiles(path))
{
File.Delete(file);
}
Upvotes: 5
Reputation: 166606
You could try
string[] files = Directory.GetFiles("Path");
foreach (string file in files)
File.Delete(file);
Upvotes: 1