Downloading from multiple folders

nooruls143

Newcomer
Joined
Sep 12, 2006
Messages
1
Hi,

I need to create a page that enables the user to download the files from his directory depending upon his username. So, each user has its own specific directory. I have been able to display the files using DataGrid and put a download button next to each row (Asp:ButtonColumn) but I am unable to trigger the download. I have created a subroutine that enables the download using file streams, and I want the button to trigger that sub whenever the user clicks on it. Please help! Also plz. provide the code if possible

Regards,
Noorul
 
What you need to do is create an Http Handler (.ashx) file. You can pass the file path to this handler in the QueryString. You then need to set the appropriate value for the ContentType property of the HttpResponse. Here's an example for an MS Word document:
C#:
byte[] bytes = null; // your file bytes here...

context.Response.ContentType = "application/ms-word";
context.Response.AddHeader("content-disposition", "inline;filename=test.doc");
context.Response.BinaryWrite(bytes);
Look around online for "HTML Content Type" for the right value for your specific file type.
 
Back
Top