tags:

views:

1037

answers:

2

Hi,

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

A: 
enter code here   ::
                       when i am using this code in asp.net3.5 it works fine

      when i install iis server it not showing the  System.Diagnostics.Process.Start(FilePath); please can you help me

protected void ImgBtnCheckin_Click(object sender, ImageClickEventArgs e) {

    string FilePath;
    FilePath = TextBoxpath.Text;
    PanDisplay.Visible = false;
    con.Open();

    if (File.Exists(FilePath))
    {
        string q = "select * from  Folderdata where status='lock' and path='" + TextBoxpath.Text + "'";
        NpgsqlCommand cmd = new NpgsqlCommand(q, con);
        object obj = cmd.ExecuteScalar();
        if (obj == null)
        {
            try
            {

                // TextBoxcontent.Enabled = true;
                System.Diagnostics.Process.Start(FilePath);

                NpgsqlCommand cmd1 = new NpgsqlCommand("INSERT INTO Folderdata VALUES('" + txt + "','" + TextBoxpath.Text + "', 'now','lock')", con);

                cmd1.ExecuteNonQuery();

                con.Close();



                ImgBtnCheckin.Visible = false;
            }
            catch (Exception e1)
            {
                Lblerror.Visible = true;
                Lblerror.Text = "Error Has occur in dropdown list" + e1.Message;
            }
        }
        else
        {
            Response.Write("<script language='javascript'>window.alert('you can't access this file now<br> please try after some time');</script>");
            DataSet ds = new DataSet();
            //con.Open();
            NpgsqlDataAdapter da = new NpgsqlDataAdapter("select * from folderdata", con);

            da.Fill(ds);
            con.Close();

            if (ds.Tables[0].Rows.Count > 0)
            {
                PanDisplay.Visible = true;
                lbluser.Text = ds.Tables[0].Rows[0][0].ToString();
                lblfile.Text = ds.Tables[0].Rows[0][1].ToString();
                lbllasttime.Text = ds.Tables[0].Rows[0][2].ToString();
                lblstatus.Text = ds.Tables[0].Rows[0][3].ToString();
            }
        }
    }      

}
mansoor
+1  A: 

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

Kragen
Great this worked - thanks!
rob