使用 .NET 创建磁盘映像
我需要克隆 CF 卡(具有一定量的自定义功能,无法使用现成的克隆工具)。我需要一个合适的图像才能正常工作 - 我不能只复制所有文件。我想用 C# 编写一个程序,但我不知道从哪里开始。
有人能给我指出一个基本示例或其他东西来让我朝着正确的方向前进吗?
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't 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用与普通文件 io 相同的 API 来读取和写入 Windows 中的卷中的原始数据。区别在于公开征集。
CreateFile("\.\M:", GENERIC_READ | GENERIC_WRITE, ...)
将打开驱动器 M: 进行原始读写。我从未尝试过,但您也许可以将“\.\M:”作为文件名传递给 C# 中的流打开函数之一,它可能可以工作。但是,明智的做法是至少用非托管代码编写项目的文件 io 部分。
有关详细信息,请参阅 CreateFile 文档。寻找该部分
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
你不能使用像这样的程序: http://xedit.smike.ru/
否则你必须后退Win32 API 调用,如 CreateFile(例如,对于驱动器 G,使用“\.\g:”作为文件名参数)
还要查看 ReadFile/WriteFile、SetFilePointer 和 DeviceIoControl 函数。
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.
您需要使用 Pinvoke 来调用块模式 io。无法复制文件的原因是什么?
You would need to use Pinvoke to call block mode io. What is the reason you cant just copy files?