Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

No application is associated with the specified file for this operation

Posted on 2009-04-01
6
Medium Priority
?
1,122 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 27

Expert Comment

by:nmarun
ID: 24056736
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

773 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