How do I delete the entire folder/ directory?

2019-09-01 08:02发布

I want to delete the entire folder or directory along with files and folders contained in it. How can I implement in C#?

3条回答
来,给爷笑一个
2楼-- · 2019-09-01 08:10

Since it is tagges c# I assume the directory is at server side.Refer this link

How to delete all files and folders in a directory?

查看更多
老娘就宠你
3楼-- · 2019-09-01 08:25

Try using

Directory.Delete(dir_path, true);

Check manual

查看更多
劫难
4楼-- · 2019-09-01 08:30
var dInfo = new DirectoryInfo("your_path_to_dir");
dInfo.Delete(true);

The true parameter in the Delete method is Recursive = true. This tells the method to delete the current folder and everything inside it. Files and folders.

查看更多
登录 后发表回答