How can i read file contents in a VHD Image

Dec 11, 2009 at 12:21 PM
Edited Dec 11, 2009 at 12:53 PM


I have created a VHD disk with include 10 files using DiscUtils API.

I can read some attributes of the VHD file like size , disc type ,geomotry ..etc. but cann't get contents.

I  am using sample application of DiscUtils i.e., VHDDump. and trying to get contents of VHD image. Please see below code:

using (Stream fileStream = File.OpenRead(_vhdFile.Value))
                using (DiskImageFile vhdFile = new DiskImageFile(fileStream))
                    DiskImageFileInfo info = vhdFile.Information;

                    FileInfo fileInfo = new FileInfo(_vhdFile.Value);                                                    

I have also tried these both way to read of this contents :

1. Disk ds = new Disk(fileStream,Ownership.None); 

2. FatFileSystem fs = new FatFileSystem(fileStream, Ownership.None);

But i cann't getting it.

How can i read  file contents in a VHD Image ..??.

If anybody  know then plz suggest me ..?




<input id="gwProxy" type="hidden" /><!--Session data--><input id="jsProxy" onclick="jsCall();" type="hidden" />

Dec 11, 2009 at 10:36 PM

Hi Rajesh,

You want to do:

Disk ds = new Disk(fileStream, Ownership.None);

Then use VolumeManager to find the partitions

You then need to use FatFileSystem or NtfsFileSystem to access the contents of the partitions





Dec 14, 2009 at 2:02 PM

Thanks Ken for this good information.