How to mount a VHD with only one partition?

112 views Asked by At

I'm developing a project and I need the code in C# to assemble a vhd, and assign a letter to it. During the process of creating the vhd, I managed to do it via cmd by diskpart, but at that time I didn't assign a letter to it because the intention is to give the option to the user which letter he wants to mount. But now to mount I have a problem because I have no way of predicting which volume it will be mounted on. PS: The VHD only have and will only have one partition.

VHD Creation Code:

process.StandardInput.WriteLine("create vdisk file=" + Path.GetTempPath() + "storagedisk.vhd" + " maximum=" + size + " type=fixed");
process.StandardInput.WriteLine("select vdisk file=" + Path.GetTempPath() + "storagedisk.vhd");
process.StandardInput.WriteLine("attach vdisk");
process.StandardInput.WriteLine("convert gpt");
process.StandardInput.WriteLine("create partition primary");
process.StandardInput.WriteLine("format fs=ntfs label=\"ProSafe Disk\" quick");
process.StandardInput.WriteLine("detach vdisk");
process.StandardInput.WriteLine("exit");
0

There are 0 answers