简体   繁体   中英

System.Diagnostics.Process.Start Issue

I seem to have a weird issue with the System.Diagnostics.Process.Start method. I have a C# Desktop application using 3.5 SP1 .NET Framework. 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. 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".

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.

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. You can find a list of command line arguments accepted by explorer.exe here:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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