Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
In my Db Table there are 4 field srno,name,path,date time. Complete Path of file in path field. now i want to download the files from directory using path when the user click on download it will get path from database and file from folder to download it. Plz guide me,
Thank to All
Posted

1 solution

Do you get path when you clicks on download.
if yes, then following code to download file
You need to take help of System.web.webclient. here is code

C#
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(FilePath) + "\"");
byte[] data=req.DownloadData(Server.MapPath(FilePath));
response.BinaryWrite(data);
response.End();


it will prompt for saving file.
 
Share this answer
 
Comments
waqar ahmad (Dev) 9-Jan-12 7:35am    
I want to display like this

srno username Downlaod Date Time

1 waqar Download 09/01/2012
2 ali Download 09/01/2012
similary other records and files also display in Grid

How is it possible plz guide me i am new in ASP.net

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