How can I download a file through my application
Hai Guys.,
Im doing an Application titled Online Educatio开发者_如何学Pythonn. In my application i have to enable the trainees to download the pdf tutorials that i've been already stored in database.How can I do this process using C#.Net..,
Thanks in advance for those who answer this question....,
Shankar.
So you are already putting your file in DB?
To allow users download file you should use Response.BinaryWrite. You will also need to send some special headers to user.
All in all the code looks like this:
Response.ContentType = "Application/pdf";
Response.AppendHeader( "content-disposition", "attachment; filename=" + name );
Response.BinaryWrite(data);
Response.End();
Pass the file to the response stream with the appropriate content type set. Then the browser will open a dialog to save or open the document.
File download using C#
精彩评论