开发者

Creating a disk image using .NET

I need to clone CF cards (with a certain amount of custom functionality that precludes using off-the-shelf cloning tools). I need a proper image for this to work - I can'开发者_如何学Ct just copy all the files. I would like to write a program for this in c#, but I have no idea where to start.

Could anyone point me to a basic sample or something to get me going in the right direction?


Cant you use a program like : http://xedit.smike.ru/

Otherwise you have to fall back to Win32 API calls, like CreateFile (for drive G, for example, use "\.\g:", as file name parameter)

Also look into the ReadFile/WriteFile, SetFilePointer and DeviceIoControl functions.


You use the same API to read and write to To read raw data from a Volume in Windows that you use for ordinary file io. The difference is in the open call.

CreateFile("\.\M:", GENERIC_READ | GENERIC_WRITE, ...)

Will open drive M: for raw read and write. I've never tried it, but you might be able to get away with passing "\.\M:" as the filename to one of the stream open functions in C#, it might work. But you would be wiser to write at least the file io part of the project in unmanaged code.

See the CreateFile documentation for more information. look for the section

Physical Disks and Volumes

Direct access to the disk or to a volume is restricted. For more information, see "Changes to the file system and to the storage stack to restrict direct disk access and direct volume access in Windows Vista and in Windows Server 2008" in the Help and Support Knowledge Base at


You would need to use Pinvoke to call block mode io. What is the reason you cant just copy files?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜