简体   繁体   English

System.Diagnostics.Process.Start问题

[英]System.Diagnostics.Process.Start Issue

I seem to have a weird issue with the System.Diagnostics.Process.Start method. 我似乎对System.Diagnostics.Process.Start方法有一个奇怪的问题。 I have a C# Desktop application using 3.5 SP1 .NET Framework. 我有一个使用3.5 SP1 .NET Framework的C#桌面应用程序。 A user clicks on a label which passes a folder path stored in it's tag as a string to the function. 用户单击标签,该标签会将存储在标签中的文件夹路径作为字符串传递给函数。 Windows Explorer launches with the correct folder. Windows资源管理器将使用正确的文件夹启动。 When this tool is installed on Citrix and is run through a published application, Windows Explorer will still launch but a .NET exception message is also displayed "The System cannot find the file specified". 当此工具安装在Citrix上并通过已发布的应用程序运行时,Windows资源管理器仍将启动,但还会显示.NET异常消息“系统找不到指定的文件”。

System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)

The file path exists as it's just launched it ok and the code works with no errors when logged locally onto the server, it just errors as a published application, my code is below 文件路径已经存在,因为它刚刚启动就可以了,并且在本地登录到服务器时代码没有错误,但作为已发布的应用程序只是错误,我的代码如下

Label label = (Label)sender;
if (label.ForeColor == Color.Blue) {
   if (System.IO.Directory.Exists(label.Tag.ToString()) == false)
   {
      MessageBox.Show("The specified folder does not exist:" + 
            Environment.NewLine + Environment.NewLine + label.Tag.ToString(), "",
            MessageBoxButtons.OK, MessageBoxIcon.Information);
      return;
   }
   System.Diagnostics.Process.Start(label.Tag.ToString()); 
}

I found this page http://forums.citrix.com/thread.jspa?messageID=1382638 but we don't have IIS on the server anyway. 我发现此页面http://forums.citrix.com/thread.jspa?messageID=1382638,但服务器上仍然没有IIS。

Can any one help? 可以帮忙吗?

Thanks, Rob 谢谢,罗伯

Instead of trying to start a process with the folder name, start the process "explorer.exe" and pass the name of the folder as a command line argument. 而不是尝试使用文件夹名称启动进程,而是启动进程“ explorer.exe”并将文件夹名称作为命令行参数传递。 You can find a list of command line arguments accepted by explorer.exe here: 您可以在此处找到explorer.exe接受的命令行参数列表:

http://support.microsoft.com/kb/314853 http://support.microsoft.com/kb/314853

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM