This project is read-only.

How can i read file contents in a VHD Image

Dec 11, 2009 at 1:21 PM
Edited Dec 11, 2009 at 1: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 11: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 3:02 PM

Thanks Ken for this good information.