menimemo
menimemo

Reputation: 1

How to extract partitions from a Stream using DiscUtils?

I'm currently using the LTRData version of DiscUtils, and I need to read a disk in order to extract its partitions. I need to pass it from Stream to VirtualDisk.

Though, my disk needs to be a Stream at the beginning (these are the specifications). I've been searching for days but nothing works.

Here's my code :

using FileStream diskStream = File.Open(diskPath, FileMode.Open, FileAccess.ReadWrite);

PhysicalVolumeInfo[] volumes = null;
VirtualDisk v2 = Disk.InitializeDynamic(stream, Ownership.None, stream.Length * 1024);
var u = PartitionTable.GetPartitionTables(v2);
BiosPartitionTable.Initialize(stream, Geometry.FromCapacity(v2.Capacity, v2.SectorSize));

var volManager = new VolumeManager(v2);
volumes = volManager.GetPhysicalVolumes(); // does not return the partitions I want
foreach (var volume in volumes)
{
    var fsInfos = FileSystemManager.DetectFileSystems(volume);
}

Here, my disk has got 4 partitions but this code only gives me 1, but why ? any idea ? What did I miss ?

Upvotes: 0

Views: 23

Answers (0)

Related Questions