string constr = ConfigurationManager.ConnectionStrings["DbConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string fileid = Request.QueryString["Id"].ToString(); string query = "select Name,Extension,EncryptedData From EncryptedFile where Id='" + fileid + "'"; SqlCommand com = new SqlCommand(query, con); com.CommandType = CommandType.Text; SqlDataReader dr1 = com.ExecuteReader(); while (dr1.Read()) { //FileStream fs1 = new FileStream("C:\\Users\\20405\\Desktop\\testpdf.pdf", FileMode.Open, FileAccess.Read); //BinaryReader br = new BinaryReader(fs1); //Document document = new Document(br); string file = dr1["Name"].ToString(); string odata = Decrypt(dr1["EncryptedData"].ToString()); string Dext = dr1["Extension"].ToString(); //byte[] data = System.Text.Encoding.UTF8.GetBytes(odata); //byte[] data = Convert.FromBase64String(odata); byte[] data = Encoding.UTF8.GetBytes(odata); Response.Clear(); MemoryStream ms = new MemoryStream(data); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + file.ToString()); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Buffer = true; ms.WriteTo(Response.OutputStream); Response.Flush(); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)