How to Download in in file
Download for pdf,documents,and video and audio use c# use in my project use download any file ...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilesh SawardekarRank #648 · 3.7K reputationPosted Jul 3, 2016, 7:58 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jul 3, 2016, 8:55 PM EDT
Rajesh GamiRank #30 · 41.5K reputationPosted Apr 12, 2018, 6:28 PM EDT
Index
NitinRank #455 · 5.5K reputationPosted Jul 3, 2016, 7:52 AM EDT
{
try
{
string strURL = txtFileName.Text;
WebClient req = new WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
byte[] data = req.DownloadData(Server.MapPath(strURL));
response.BinaryWrite(data);
response.End();
}
catch (Exception ex)
{
}
}
Manoj BhoirRank #599 · 4K reputationPosted Jul 3, 2016, 8:49 AM EDT
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;response.ClearContent();response.Clear();response.ContentType = "APPLICATION/OCTET-STREAM";response.AddHeader("Content-Disposition", "attachment; filename=" + yourfileName + ";");response.TransmitFile(Server.MapPath("FileName"));response.Flush();response.End();Munesh SharmaRank #174 · 13.9K reputationPosted Jul 3, 2016, 8:55 AM EDT
Jyothi Augustine57 reputationPosted Mar 16, 2018, 1:54 AM EDT
Jyothi Augustine57 reputationPosted Mar 16, 2018, 1:57 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Apr 5, 2018, 11:06 PM EDT
Rajesh GamiRank #30 · 41.5K reputationPosted Apr 13, 2018, 10:24 PM EDT