Click here to Skip to main content
15,911,141 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi
i upload my file to server file on my asp web project and save the path in database
now i try to download it
how can i do that with simple code
my path is "~/StatisticalsFiles/UploadFile1.xlsx"

please help :)
Posted
Comments
ZurdoDev 6-Jan-16 10:40am    
The simplest code is to create a hyperlink to the file.
Suvendu Shekhar Giri 6-Jan-16 10:43am    
Anything you have tried so far?
Check @RyanDev's suggestion.
sam9787 6-Jan-16 11:10am    
string filePath =Server.MapPath(myrow["UploadFile"].ToString());
HttpResponse res = HttpContext.Current.Response;
res.Clear();
res.AppendHeader("content-disposition", "attachment; filename=" + filePath);
res.ContentType = "application/octet-stream";
res.WriteFile(filePath);
res.Flush();
res.End();



itry this code and work fine but the file language is corrupted ????
Sergey Alexandrovich Kryukov 6-Jan-16 14:29pm    
If you already store files in your server's host file system, why wouldn't you simply generate an anchor in one of your ASP.NET page?
—SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900