DriveTool.cs 885 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using Y.Utils.DataUtils.Collections;
  7. namespace Y.Utils.IOUtils.DriveUtils
  8. {
  9. public class DriveTool
  10. {
  11. /// <summary>
  12. /// 获取磁盘上次格式化时间
  13. /// </summary>
  14. /// <param name="dstr"></param>
  15. /// <returns></returns>
  16. public static DateTime GetLastFormatTime(string dstr)
  17. {
  18. string volInfo = dstr + "System Volume Information";
  19. DateTime result = DateTime.Now;
  20. if (Directory.Exists(volInfo))
  21. {
  22. try
  23. {
  24. DirectoryInfo di = new DirectoryInfo(volInfo);
  25. result = di.CreationTime;
  26. }
  27. catch (Exception e) { }
  28. }
  29. return result;
  30. }
  31. }
  32. }