Last post Aug 13, 2010 05:07 AM by Bhaarat
Aug 10, 2010 10:03 AM|poojadixit|LINK
i have designed an c#.net application in which i am uploading the files and saving them into a directory.
now i want to download them.
i had wrote a code to download files,its neither giving any result nor error.
please help me.
the code is as :
WebClient fileReader = new WebClient();
byte byteArray = null;
Uri address = new Uri("E://FileUpload/" + filepath);
byteArray = fileReader.DownloadData(address);
string content = System.Text.Encoding.ASCII.GetString(byteArray);
Response.AddHeader("content-disposition", "attachment,filename=" + filename);
Aug 10, 2010 11:25 AM|Metalore|LINK
Why not just provide a link to the actual file on the server, when user clicks on that link he / she will be prompted to open / save the file :)
Aug 13, 2010 04:44 AM|Ming Xu - MSFT|LINK
According to your description,you need not to use WebClient at all.
Here is a sample:
Code in .cs:
protected void Page_Load(object sender, EventArgs e)
string filename = "Ming XU.txt";//file name which used to download
string filepath = "files/book1.txt";//where you want to download the file
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
Response.ContentType = "application//octet-stream";
Please check the link below.Hope it can help you.
Aug 13, 2010 05:07 AM|Bhaarat|LINK