Sreejesh Kumar
Sreejesh Kumar

Reputation: 2499

delete files from folder

How do you remove files from a folder using ASP.Net with C# ?

Upvotes: 2

Views: 4133

Answers (3)

ZombieSheep
ZombieSheep

Reputation: 29963

Same as the above answers, but lambda-fied, if that's your thing...

Array.ForEach(Directory.GetFiles(path), File.Delete);

Upvotes: 3

sashaeve
sashaeve

Reputation: 9617

foreach (var file in Directory.GetFiles(path))
{
       File.Delete(file);
}

Upvotes: 5

Adriaan Stander
Adriaan Stander

Reputation: 166606

You could try

string[] files = Directory.GetFiles("Path");
foreach (string file in files)
    File.Delete(file);

Upvotes: 1

Related Questions