I want to extract a file from vhdx file. There is a way to do this. -Mount the disk and read file from mounted location. But I want to write a CPP/C# code for this. I am able to get vhdx file details with MS provided API (visrtdisk.dll) which consists files size, GUID, etc, but I am not getting any API which can give me the disk structure (MBE/Partitions/FileSystem/etc) from given vhdx file.
Asked
Active
Viewed 1,706 times
4
-
It is operating system specific – Basile Starynkevitch Mar 05 '16 at 07:51
-
Voted to close as asking for a library recommendation. – Cheers and hth. - Alf Mar 05 '16 at 07:52
1 Answers
3
Please see this C# library http://discutils.codeplex.com/, it is very comprehensive library and supports lot of file systems (including VHD, VHDx, ISO, EXT, HFS, HFSPlus etc.)
[The sample taken from home page and modified it for vhdx instead of 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...
}
}

A.B.
- 1,554
- 1
- 14
- 21
-
Downvoted as answer to off-topic question about library recommendation. – Cheers and hth. - Alf Mar 05 '16 at 07:52