Home > DeveloperSection > Forums > Downloading a file found in my solution folder
Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    October-05-2013 2:26 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 686  View(s)
Rate this:

Guys I am making an application that plays a media file from a folder of my solution. I have to allow the user to download the very file that is playing. Any help?

I am on VS2010 (c#)



Dag Hammarskjold
Dag Hammarskjold

Total Post:24

Points:168
Posted on    October-05-2013 4:13 AM

Take a look at this short sample code:

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.pdf");
Response.TransmitFile(Server.MapPath("~/Files/MyFile.pdf"));
Response.End();

You can get to the file in your solution with the Server.MapPath method.


Don't want to miss updates? Please click the below button!

Follow MindStick