Click or drag to resize

DiskPartitionInfoProvider Constructor

Initializes a new instance of the DiskPartitionInfoProvider class.

Namespace:  Xcalibur.WMI.Hardware.Disk
Assembly:  Xcalibur.WMI (in Xcalibur.WMI.dll) Version: 3.0.0.0 (3.0.1.0)
Syntax
public DiskPartitionInfoProvider(
	ManagementScope ms,
	int id = -1
)

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
id (Optional)
Type: SystemInt32
The specific Disk Index.
Examples
C#
 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    // Disk Drive Partition Info Provider
14    var provider = new DiskPartitionInfoProvider(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                          $"{info.Size}, " +
24                          $"\t{info.StartingOffset}, " +
25                          $"\t{info.Description}");
26    }
27
28    // Read
29    Console.Read();
30}
31
32/* Results: 
33 * 
34 * Disk #0, Partition #0, 471859200,       1048576,        GPT: Unknown
35 * Disk #0, Partition #1, 104857600,       472907776,      GPT: System
36 * Disk #0, Partition #2, 274284412928,    594542592,      GPT: Basic Data
37 * Disk #0, Partition #3, 450448003072,    274878955520,   GPT: Basic Data
38 * Disk #0, Partition #4, 274877906944,    725326958592,   GPT: Basic Data
39 * 
40 */
See Also