123456789101112131415161718192021222324252627282930313233 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices.ComTypes;
- using System.Text;
- using System.Threading.Tasks;
- namespace NNCapTest
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- var dirs = new string[] { "D:\\Data;E:\\Data" };
- //配置了多个存储目录,选容量最大的那个目录
- var dir = dirs.Where(p =>
- {
- var root = Path.GetPathRoot(p);
- DriveInfo drive = new DriveInfo(root);
- return drive.IsReady && drive.TotalSize > 0;
- }).OrderByDescending(p =>
- {
- var root = Path.GetPathRoot(p);
- DriveInfo drive = new DriveInfo(root);
- return drive.TotalSize;
- }).FirstOrDefault();
- var DataDir = dir;
- }
- }
- }
|