Process.Start不能使用UNC路径启动Filezilla

3

这段代码原本在C盘上运行良好,但现在我们将其移动到了一个UNC路径\share上,似乎无法重新加载配置文件。没有错误提示,Filezilla正常工作,我可以连接并在这个UNC共享上传输文件,但是通过代码无法实现预期的功能。我需要做一些特殊的凭据吗?我的应用程序池用户账户与共享账户相同。

Process.Start("CMD.exe", "/C \"\\filezilla\\FileZilla Server.exe\" /reload-config");

更新

我在实际电脑上的命令提示符中运行了这条命令,并且它达到了预期的效果。

另一个更新

var path = string.Format("/C \"{0}FileZilla Server.exe\" /reload-config", Config.Paths.FileZillaPath); // \\filezilla\
Process.Start("CMD.exe", path);
Logger.Debug("Path: " + path); // Path: /C "\\filezilla\FileZilla Server.exe" /reload-config
2个回答

10

你在UNC路径中的第一对反斜杠没有被正确转义,将导致仅显示一个反斜杠。尝试使用

Process.Start("CMD.exe", "/C \"\\\\filezilla\\FileZilla Server.exe\" /reload-config");

您可以在MSDN上看到一个示例

string g = "\\\\server\\share\\file.txt"; // \\server\share\file.txt

string h = @"\\server\share\file.txt"; // \\server\share\file.txt


新的更新在上面吗?路径输出/C "\\filezilla\FileZilla Server.exe" /reload-config - Mike Flynn
是的,那看起来是正确的。它还没有运行吗?如果是这样,请打开一个命令窗口并运行 CMD.exe /C "\\filezilla\FileZilla Server.exe" /reload-config,以查看是否有任何错误。(我相信您已经这样做了,但请检查语法是否匹配)。 - Tone

3

我曾经做过类似的事情,但是像这样...

 Process reloadConfig = new Process();
 reloadConfig.StartInfo.FileName = @"\\MachineName\FileZilla Server\FileZilla Server.exe\";
 reloadConfig.StartInfo.Arguments = @"/reload-config";
 reloadConfig.Start();

并且这个对我来说可行。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接