UsbLinuxPartitionManager.DiskpartPartitionOperations

Diskpart-backed partition operations for WinPE. Uses the NETCommand builder pattern (UsbLinuxPartitionManager.DiskpartPartitionOperations.DiskpartCommand) rather than raw ProcessStartInfo. Diskpart is proven reliable in WinPE, unlike PowerShell Storage cmdlets which can silently fail to shrink GPT partition entries.

public static class UsbLinuxPartitionManager.DiskpartPartitionOperations

1. Methods

1.1. AssignDriveLetter(ISystemHost, IDisk, int)

Assigns the first free drive letter to the given partition via diskpart (assign with no arguments picks the first free letter), then re-reads the disk and returns the assigned letter.

public static char AssignDriveLetter(ISystemHost host, IDisk disk, int partitionNumber)
Table 1. Parameters
Name Type Description

host

ISystemHost

disk

IDisk

partitionNumber

int

Returns: char

1.2. CreatePartition(ISystemHost, IDisk, string, string)

Creates a new primary partition in the unallocated space of disk and formats it with the given fileSystem and label. Returns the partition number of the newly created partition (resolved by re-reading the disk’s partitions after the operation and matching the label).

public static int CreatePartition(ISystemHost host, IDisk disk, string fileSystem, string label)
Table 2. Parameters
Name Type Description

host

ISystemHost

disk

IDisk

fileSystem

string

label

string

Returns: int

1.3. ResizePartition(ISystemHost, IDisk, int, DataSize)

Shrinks the given partition to plannedSize using diskpart.

public static void ResizePartition(ISystemHost host, IDisk disk, int partitionNumber, DataSize plannedSize)
Table 3. Parameters
Name Type Description

host

ISystemHost

disk

IDisk

partitionNumber

int

plannedSize

DataSize