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...
}
}