How can I download a file

Last post 03-11-2009 3:25 AM by anandkbs. 3 replies.

Sort Posts:

  • How can I download a file

    07-05-2007, 2:36 AM

    I want to add a link through where customer can download file.How can i do that.Please help.

  • Re: How can I download a file

    07-05-2007, 3:33 PM
    Answer
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs
    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: How can I download a file

    07-05-2007, 3:38 PM
    • Contributor
      5,529 point Contributor
    • keyboardcowboy
    • Member since 06-14-2007, 7:39 PM
    • Thornhill Ontario
    • Posts 1,045

     in the links click event you can do

    Response.Redirect("locationofthefile.filetype");
    
    normally that will link to another page, but when the file type is not a web format, so say something like .mp3, it will prompt for a download
    Please remember to click "Mark as Answer" on this post if it helped you.
  • Re: How can I download a file

    03-11-2009, 3:25 AM
    • Member
      742 point Member
    • anandkbs
    • Member since 11-13-2008, 9:36 AM
    • Bangalore
    • Posts 150

    Just send the full file name of the file that as to be downloaded.

     private void DownloadFile(string FileName)
     {
            Response.AddHeader("Content-Disposition", "attachment;filename=" +              HttpUtility.UrlEncode(FileName));

            Response.ContentType = "application/octet-stream";
            Response.TransmitFile(FileName);
    }  

    If you mark as "Answer" then others can use this answer as a reference.

    Any suggestions,
Page 1 of 1 (4 items)