private void OpenMyFile() { string path = GetPath() + ViewState["fileopen"]; FileInfo file = new FileInfo(ViewState["fileopen"].ToString()); SqlConnection con = new SqlConnection(@"server=servername;database=DBNAME;uid=ID;pwd=PWD;max pool size=250;Connect Timeout=0"); con.Open(); cmd = new SqlCommand("select * from filetypemaster where extension='" + file.Extension + "'", con); myReader = cmd.ExecuteReader(); if (myReader.Read()) { Response.ContentType =(String)myReader["CONTENT_TYPE"]; myReader.Close(); } else { myReader.Close(); Message("Cannot open selected file"); return; } Response.WriteFile(path); Response.End(); con.Close(); }
Response.ContentType = "image/jpeg"; Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.jpg"); Response.TransmitFile( Server.MapPath("~/images/sailbig.jpg") ); Response.End();
Response.AppendHeader("Content-Disposition","attachment; filename=Temp." + file.Extension);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)