Program.cs 918 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices.ComTypes;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace NNCapTest
  9. {
  10. internal class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. var dirs = new string[] { "D:\\Data;E:\\Data" };
  15. //配置了多个存储目录,选容量最大的那个目录
  16. var dir = dirs.Where(p =>
  17. {
  18. var root = Path.GetPathRoot(p);
  19. DriveInfo drive = new DriveInfo(root);
  20. return drive.IsReady && drive.TotalSize > 0;
  21. }).OrderByDescending(p =>
  22. {
  23. var root = Path.GetPathRoot(p);
  24. DriveInfo drive = new DriveInfo(root);
  25. return drive.TotalSize;
  26. }).FirstOrDefault();
  27. var DataDir = dir;
  28. }
  29. }
  30. }