[英]Read drive information of virtual machine with c#
我仍在編寫一個小型程序,試圖監視各種計算機數據,例如溫度,時鍾速度...(CPU,GPU,驅動器,RAM)。 數據主要通過OpenHardwareMonitor的WMI接口接收,可以正常工作。 但是OHM沒有提供任何有用的雲端硬盤數據,因此我目前正在從Windows WMI界面中讀取數據。 (Win32_DiskDrive)
如果您在物理機上工作,一切都會正常運行。 但是,當我在虛擬機中嘗試它時,我根本沒有收到任何驅動器數據。
您是否知道我應該怎么做才能在虛擬機上獲取重要的驅動器數據? 我需要使用的空間和虛擬驅動器的總驅動器空間。 此外,如果我能夠獲得計算機物理驅動器的溫度和SMART狀態,那將很好。
謝謝你的幫助!
您是否嘗試過使用System.IO
功能?
在這里看看,可能是您所需要的!
這使您可以執行以下操作(來自鏈接):
// You can also use System.Environment.GetLogicalDrives to
// obtain names of all logical drives on the computer.
System.IO.DriveInfo di = new System.IO.DriveInfo(@"C:\");
Console.WriteLine(di.TotalFreeSpace);
Console.WriteLine(di.VolumeLabel);
// Get the root directory and print out some information about it.
System.IO.DirectoryInfo dirInfo = di.RootDirectory;
Console.WriteLine(dirInfo.Attributes.ToString());
另外,顯示您實際使用的/不起作用的代碼也很高興出現在您的問題中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.