我正在尝试通过工作组连接到计算机。我的代码如下:
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.Username = "testusername";
options.Password = "testpwd";
ManagementScope scope = new ManagementScope(@"\\19x.16x.x.xx\C$\TestFolder", options);
scope.Connect();
if (scope.IsConnected == true)
{
MessageBox.Show("Connection Succeeded", "Alert");
}
else
{
MessageBox.Show("Connection Failed", "Alert");
}
当我运行它时,我得到异常:“无效参数”
如何解决这个问题?
编辑:
错误在下面的这一行:
ManagementScope scope = new ManagementScope(@"\\19x.16x.x.xx\C$\TestFolder", options);
我们如何指定驱动器?我认为 $ 是造成问题的原因