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.