[英]How do I mount a VHD using C# code without invoking a diskpart script?
In my Azure role I want to mount a VHD - roughly have an equivalent of the following diskpart
commands: 在我的Azure角色中,我想挂载VHD - 大致相当于以下
diskpart
命令:
vdisk select VhdFilePath
vdisk attach
This answer explains how to create a script and then programmatically invoke it from C#. 这个答案解释了如何创建脚本,然后以编程方式从C#调用它。
Is there a way to achieve the same without a script - just with some .NET classes? 有没有办法在没有脚本的情况下实现相同的功能 - 只需要一些.NET类?
I don't know if there's a managed API to do this, but there are a few examples of C# wrappers around some native methods: 我不知道是否有托管API来执行此操作,但有一些C#包装器的示例围绕一些本机方法:
http://www.jmedved.com/2009/05/open-and-attach/ http://www.jmedved.com/2009/05/open-and-attach/
And since this wraps around the AttachVirtualDisk method I assume it should also work for Windows Server 2008 R2 (note that you'll need to set the osFamily of your role to 2 in order to get the R2 ). 由于这包含了AttachVirtualDisk方法,我认为它也适用于Windows Server 2008 R2(请注意,您需要将角色的osFamily设置为2才能获得R2 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.