How do I delete the entire folder/ directory?

别来无恙 提交于 2019-12-11 18:40:07

问题


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


回答1:


Try using

Directory.Delete(dir_path, true);

Check manual




回答2:


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:


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.



来源:https://stackoverflow.com/questions/10732510/how-do-i-delete-the-entire-folder-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!