01.using System.IO;
02.using System.Linq;
03.
04.namespace FileFolderDeleter
05.{
06. static class Program
07. {
08. static void Main(string[] args)
09. {
10. if (args.Count() == 1)
11. {
12. DeleteFilesAndFolders(args[0]);
13. }
14. }
15.
16. /// <summary>
17. /// Recursively delete all the files and folders under the specific path.
18. /// </summary>
19. /// <param name="path">The specific path</param>
20. private static void DeleteFilesAndFolders(string path)
21. {
22. // Delete files.
23. string[] files = Directory.GetFiles(path);
24. foreach (var file in files)
25. {
26. File.Delete(file);
27. }
28.
29. // Delete folders.
30. string[] folders = Directory.GetDirectories(path);
31. foreach (var folder in folders)
32. {
33. DeleteFilesAndFolders(folder);
34. Directory.Delete(folder);
35. }
36. }
37. }
38.}
C#递归删除某一路径下的所有文件和文件夹的代码下载如图片无法显示或论文不完整,请联系qq752018766