How to get files (or file system) from a VHDX file using CPP / C #

I want to extract a file from a vhdx file. There is a way to do this. - Install the drive and read the file from the installed location. But I want to write CPP / C # for this. I can get information about a vhdx file using the MS API (visrtdisk.dll) which contains the file size, GUID, etc., but I don't get any API that can give me the disk structure (MBE / Partitions / FileSystem / etc) from the given vhdx file.

+3
source share
1 answer

Please see this C # library http://discutils.codeplex.com/ , it is a very complete library and supports many file systems (including VHD, VHDx, ISO, EXT, HFS, HFSPlus, etc.)

[, vhdx vhd].

long diskSize = 30 * 1024 * 1024; //30MB
using (Stream vhdStream = File.Create(@"C:\TEMP\mydisk.vhdx"))
{
    Disk disk = Disk.InitializeDynamic(vhdStream, diskSize);
    BiosPartitionTable.Initialize(disk, WellKnownPartitionType.WindowsFat);
    using (FatFileSystem fs = FatFileSystem.FormatPartition(disk, 0, null))
    {
        fs.CreateDirectory(@"TestDir\CHILD");
        // do other things with the file system...
    }
}
0

All Articles