简体   繁体   中英

delete files from folder

如何使用带有C#的ASP.Net从文件夹中删除文件?

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

和上面的答案一样,但是如果那是你的话,那就是lambda-fied ......

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

You could try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM