sir , how we can download a file (excel file) from a website using that website url(.csv)using c#
,that file should download and save in in my system...plzz tell me tha full procedure
regards
puneetsharma
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
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 23, 2014, 12:35 AM EDT
protected void lnkfilepath_Click(object sender, EventArgs e) // ur link button
{
string filename = lnkfilepath.Text;
string Filpath = Server.MapPath("~/Attachments/" + filename);
DownLoad(Filpath);
}
public void DownLoad(string FName)
{
string path = FName;
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream"; // download all types of files..
Response.WriteFile(file.FullName);
Response.End();
}
else
{
Response.Write("This file does not exist.");
}
}
Refer thiz link http://rajeeshmenoth.wordpress.com/2014/06/25/how-to-download-files-using-asp-net-c/