开发者

delete files from folder

开发者 https://www.devze.com 2022-12-19 17:07 出处:网络
How do you remove files fr开发者_如何学Goom a folder using ASP.Net with C# ?foreach (var file in Directory.GetFiles(path))

How do you remove files fr开发者_如何学Goom a folder using ASP.Net with C# ?


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


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

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


You could try

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

精彩评论

暂无评论...
验证码 换一张
取 消