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
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);
}
}
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.EnableRaisingEve nts = false;
myProcess.StartInfo.FileNa me = strPath;
myProcess.StartInfo.Window Style = System.Diagnostics.Process WindowStyl e.Maximize d;
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
System.Diagnostics.Process
myProcess.EnableRaisingEve
myProcess.StartInfo.FileNa
myProcess.StartInfo.Window
myProcess.Start();
Say the file name is c:\temp\Music\playlist.dat
No application is associated with the specified file for this operation
ASKER
So please give me the solution for this problem..urgent
Please have a look at these links to see how file uploading is done:
http://msdn.microsoft.com/en-us/library/aa479405.aspx
http://www.4guysfromrolla.com/webtech/091201-1.shtml
http://www.codeproject.com/KB/aspnet/fileupload.aspx
http://msdn.microsoft.com/en-us/library/aa479405.aspx
http://www.4guysfromrolla.com/webtech/091201-1.shtml
http://www.codeproject.com/KB/aspnet/fileupload.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank u sir its help ful