public void TestHardDiskSpaceManager_GetHardDiskSpace() { long lengthDisk = HardDiskSpaceManager.GetHardDiskSpace(@"D:\"); Console.WriteLine($"D盘总空间: {lengthDisk}"); long lengthFree = HardDiskSpaceManager.GetHardDiskFreeSpace(@"D:\"); Console.WriteLine($"D盘剩余空间: {lengthFree}"); }
private void hardDiskFreeSpaceCheck() { string diskName = new DirectoryInfo(GlobalData.Path).Root.FullName; long lengthDisk = HardDiskSpaceManager.GetHardDiskSpace(diskName); Logger.Default.Trace($"{diskName} 盘总空间: {lengthDisk}"); while (true) { long lengthFree = HardDiskSpaceManager.GetHardDiskFreeSpace(diskName); if (lengthFree < GlobalData.HardDiskFreeSpaceInf) { Logger.Default.Trace($"{diskName} 盘剩余空间: {lengthFree}, 剩余空间不足 {GlobalData.HardDiskFreeSpaceInf}"); VideoStoragerManager.DeleteEarliestVideo(); //删除最早的视频 } else { Thread.Sleep(TimeSpan.FromMinutes(1)); } Thread.Sleep(TimeSpan.FromSeconds(1)); } }