Solved

No application is associated with the specified file for this operation

Posted on 2009-04-01
6
696 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
Comment Utility
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
Comment Utility
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
Comment Utility
So please give me the solution for this problem..urgent
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 27

Expert Comment

by:nmarun
Comment Utility
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
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
Comment Utility
thank u sir its help ful
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now