欢迎访问本站!今天是:
您现在所在的位置:欢乐棋牌 > 欢乐棋牌 > 重要通知 >

真人在线赌博棋牌游戏TotalSpace =GetDriveData (drive.TotalSize )

2019-09-03 [文号]: 来源:keraon 浏览次数:

.NET FrameWork已经把这些API封装到.NET类库中了。

MidpointRounding.AwayFromZero);} 3.获取占用内存的百分比 public double GetMemoryPercent(){var usedMem = this.cinf.TotalPhysicalMemory - this.cinf .AvailablePhysicalMemory ;//总内存减去可用内存return Math.Round((double)(usedMem / Convert.ToDecimal(this.cinf.TotalPhysicalMemory) * 100),Name =drive .Name };}/// summary/// 获取全体驱动盘信休/// /summary/// returns/returnspublic IEnumerableHardDiskInfo GetAllHardDiskInfo(){ListHardDiskInfo list = new ListHardDiskInfo();foreach (DriveInfo d in DriveInfo.GetDrives()){if (d.IsReady){list.Add(new HardDiskInfo { Name = d.Name, TotalSpace = this.GetDriveData(d.TotalSize) });}}return list;}private string GetDriveData(long data)//将磁盘大小的单位由byte转化为G{return (data / Convert.ToDouble(1024) / Convert.ToDouble(1024) / Convert.ToDouble(1024)).ToString("0.00");}class HardDiskInfo//自定义类{public string Name { get; set; }public string FreeSpace { get; set; }public string TotalSpace { get;set;}} 运行结果: ,我们想获取CPU,欢乐99棋牌官网,内存等信休就不得不借助win32 API来实现,2,就起头实践吧: 1.初始化几个变量: this.cpu = new PerformanceCounter(Processor, 正在以前,MidpointRounding.AwayFromZero);} 4.获取磁盘渣滓空间及总空间 /// summary/// 根据盘符获取磁盘信休/// /summary/// param/param/// returns一个自定义类对象/returnspublic HardDiskInfo GetHardDiskInfoByName(string diskName){DriveInfo drive = new DriveInfo(diskName);return new HardDiskInfo { FreeSpace = GetDriveData(drive.AvailableFreeSpace), 2。

先容几个要用到的类: PerformanceCounter:外示windows NT机能计数器组件 ComputerInfo:提供用于获取与推算机内存,欢乐99棋牌下载, _Total); this.cinf = new ComputerInfo(); 2.获取占用CPU的百分比 public double GetCpuPercent(){var percentage = this.cpu.NextValue();return Math.Round(percentage,但此刻,TotalSpace =GetDriveData (drive.TotalSize ),欢乐99棋牌官网, % Processor Time,起首。

FreeSpace = this.GetDriveData(d.AvailableFreeSpace),已加载程序集,欢乐棋牌,名称和操作系统有闭信休的属性 DriveInfo:该类位于System.IO命名空间下,以是我们能够借助.NET类库很轻松的获取这些信休。

提供对有闭驱动器信休的接见 先容完几个必要的类。

分享到: