Solved

No application is associated with the specified file for this operation

Posted on 2009-04-01
6
910 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:mannevenu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24051747
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.
0
 
LVL 27

Expert Comment

by:nmarun
ID: 24052385
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
0
 

Author Comment

by:mannevenu
ID: 24056716
So please give me the solution for this problem..urgent
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 27

Expert Comment

by:nmarun
ID: 24056736
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24057841
What do you want to acheive really? What type of files are uploaded by users? Are these images or other files as well? I think you need something like this.

Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", _
  "attachment; filename=""" & filename & """")
0
 

Author Closing Comment

by:mannevenu
ID: 31565640
thank u sir its help ful
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question