FileSystem.cs 834 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.VisualBasic.FileIO;
  5. using System.IO;
  6. namespace CommonFroms
  7. {
  8. public static class FileSystem
  9. {
  10. public static int DeleteToRecycleBin(string path)
  11. {
  12. if (File.Exists(path))
  13. {
  14. Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(
  15. path,
  16. UIOption.OnlyErrorDialogs,
  17. RecycleOption.SendToRecycleBin);
  18. }
  19. else if (Directory.Exists(path))
  20. {
  21. Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(
  22. path,
  23. UIOption.OnlyErrorDialogs,
  24. RecycleOption.SendToRecycleBin);
  25. }
  26. return 0;
  27. }
  28. }
  29. }