LogicalDiskInfoProvider Constructor |
Namespace: Xcalibur.WMI.Hardware.Disk
1// Main 2private static void Main() 3{ 4 // Make a connection to the local machine 5 const string computer = "."; 6 var managementScope = new ManagementScope($@"\\{computer}\root\cimv2", new ConnectionOptions 7 { 8 Impersonation = ImpersonationLevel.Impersonate, 9 Authentication = AuthenticationLevel.Connect 10 }); 11 managementScope.Connect(); 12 13 // Logical Disk Info Provider 14 var provider = new LogicalDiskInfoProvider(managementScope); 15 16 // Fetch data 17 provider.Refresh(); 18 19 // Print 20 foreach (var info in provider.Results) 21 { 22 Console.WriteLine($"{info.DeviceId} " + 23 $"\t{info.Size} " + 24 $"\t{info.FreeSpace} " + 25 $"\t{info.Description} " + 26 $"\t{info.FileSystem} " + 27 $"\t{info.StatusInfo}"); 28 } 29 30 // Read 31 Console.Read(); 32} 33 34/* Results: 35 * 36 * C: 274284408832 167196585984 Local Fixed Disk NTFS Enabled 37 * D: 450447998976 128484089856 Local Fixed Disk NTFS Enabled 38 * E: 274877902848 124919554048 Local Fixed Disk NTFS Enabled 39 * R: 3932891152384 3525185687552 Network Connection NTFS Enabled 40 * S: 3932891152384 3525185687552 Network Connection NTFS Enabled 41 * 42 */