Link to home
Start Free TrialLog in
Avatar of mannevenu
mannevenu

asked on

No application is associated with the specified file for this operation

I am working on a web application and in that i have a small functionality to upload files to web server. As per the functionality user can upload file to webserver and after uploading can view the uploaded file.
the code for viewing is given below
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {              
   
        try
        {
           
            SelectMaster SelectMaster = new SelectMaster();
            string qry = "select Content_Id,Record_Type,Description from Admn_Course_Organization where Id='" + TreeView1.SelectedNode.Value + "' ";
            DataTable dt_Fill_TV = BusinessLayer.SelectMaster.GetDataTable(Session["ConStr"].ToString(), qry);
            string cid = dt_Fill_TV.Rows[0][0].ToString();
            string recort_type = dt_Fill_TV.Rows[0][1].ToString();
            string desc = dt_Fill_TV.Rows[0][2].ToString();
            if (recort_type.ToString().Equals("OPT"))
            {
                txtdesc.Visible = true;
                txtdesc.Text = desc.ToString();
 
            }
           
            else
            {
                txtdesc.Visible = false;
                txtdesc.Text = "";
                string qry1 = "select File_Path  from Admn_Content_Mast where Id='" + cid.ToString() + "'";
                DataTable dt_Fill_TV1 = BusinessLayer.SelectMaster.GetDataTable(Session["ConStr"].ToString(), qry1);
                string path = dt_Fill_TV1.Rows[0][0].ToString();
 
              
                 
                string strPath = Server.MapPath("..\\Head_Office_Content") + "\\" +path.ToString();
                if (File.Exists(strPath))
                {
                    System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
                    myProcess.EnableRaisingEvents = false;
                    myProcess.StartInfo.FileName = strPath;
                    myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
                    myProcess.Start();
                }
                else
                {
                    string strMsg = "No file to view.";
 
                    Label lbl = new Label();
 
                    lbl.Text = ("<script language=\'javascript\'>"
 
                    + (Environment.NewLine + ("window.alert(" + ("\'"
                    + (strMsg + ("\'" + ")</script>"))))));                  
                    Page.Controls.Add(lbl);
 
                }
            }

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

The code you have written to open the file would execute on the server and the opened file would not be visible to the client. May be you want to show them some thumbnail of the image or something.
You're getting that error because your server does not know how to open one of the file.

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.EnableRaisingEvents = false;
myProcess.StartInfo.FileName = strPath;
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
myProcess.Start();

Say the file name is c:\temp\Music\playlist.dat. When you run this, the server does not know what application to open this file with and that's when it says:

No application is associated with the specified file for this operation
Avatar of mannevenu
mannevenu

ASKER

So please give me the solution for this problem..urgent
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank u sir its help ful