DriveUtil.cs 646 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. namespace Ips.Library.Basic.IO
  7. {
  8. public static class DriveUtil
  9. {
  10. public static DriveInfo GetMaxDrive()
  11. {
  12. return DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed).OrderByDescending(m => m.TotalSize).First();
  13. }
  14. public static string GetMaxDrivePath(params string[] dirs)
  15. {
  16. var drive = GetMaxDrive();
  17. string dirPath = Path.Combine(dirs);
  18. var result = Path.Combine(drive.Name, dirPath);
  19. return result;
  20. }
  21. }
  22. }