0
我想问一下如何使用GuestFileManager在访客虚拟机上创建一个目录?有人可以提供示例代码吗?因为当我打电话给MakeDirectoryInGuest()时,我总是得到异常,非常感谢。如何在Vsphere API中使用GuestFileManager?
_service = _client.Connect(_hostName);
NameValueCollection nvcFilter = new NameValueCollection();
nvcFilter.Add("Name", "W81x64");
_vm = (VirtualMachine)_client.FindEntityView(typeof(VirtualMachine), null, nvcFilter, null);
string DirectoryPath = @"C:\TestFolder\";
NamePasswordAuthentication auth = new NamePasswordAuthentication();
auth.Password = "admin";
auth.Username = "password";
auth.InteractiveSession = false;
GuestFileManager guestfilemgr = new GuestFileManager(VimClient, _service.FileManager);
guestfilemgr.MakeDirectoryInGuest(_vm.Runtime.Host,auth, DirectoryPath, true);
“MakeDirectoryInGuest”的第一个参数应该是VM越多,但它似乎是通过主机?你遇到了什么错误? – YSK
感谢您回复我的消息。我发现这个错误是因为密码和用户名在这种情况下是错误的。 – pen