DOWNLOADING A FILE FOUND IN MY SOLUTION FOLDER

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 917  View(s)
Ratings:
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#)

  1. Dag Hammarskjold

    Post:24

    Points:168
    Re: Downloading a file found in my solution folder

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!