我正在尝试将网络驱动器映射到用 c# 编写的 Windows 服务内的服务器上。我尝试使用带有以下代码的 net.exe
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "net.exe";
p.StartInfo.Arguments = " use " + DriveLetter + Path + " " + Password + " /user:" + Username;
p.Start();
p.WaitForExit();
参数基本上转换为“使用 X: \\192.45.xx.xxx\sharename "xxxx" /user: domainname\username”
执行此操作时出现“未找到网络名称”错误。我尝试访问的服务器与我的应用程序所在的域不同,这就是我认为我收到该错误的原因。
有谁知道我怎样才能克服这个问题并将另一个域的共享文件夹映射到我的本地计算机上?
我将不胜感激任何帮助
谢谢卡提克