Get current CPU, RAM and Disk drive usage in C#

后端 未结 3 1433
渐次进展
渐次进展 2020-12-05 00:54

How to get the CPU, RAM and Disk drive usage of the system in C# code?

3条回答
  •  -上瘾入骨i
    2020-12-05 01:21

    Drives

    static void Main(string[] args)
    {
    var drives = DriveInfo.GetDrives();
    foreach (DriveInfo info in drives)
    {
          Console.WriteLine("Name: {0}\nSize: {1}\nDrive Format: {2}", info.Name, info.TotalSize, info.DriveFormat);
    }
     Console.ReadLine();
    }
    

提交回复
热议问题