How To Download File Code In ASP.Net?

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Shane
    Senior Member
    • Jun 2006
    • 264

    How To Download File Code In ASP.Net?

    One can use below mentioned ASP.Net code upon the requirement to download file:

    Dim fst As New FileStream(Server.MapPath("abc.txt"), FileMode.Open)
    Dim fl As String
    if = "abc.txt"

    Dim bytBytes(fst.Length) As Byte
    fst.Read(bytBytes, 0, fst.Length)

    fst.Close()
    Response.AddHeader("Content-disposition", "attachment; filename=" & fl)
    Response.ContentType = "application/octet-stream"
    Response.BinaryWrite(bytBytes)
    Last edited by admin; 08-21-2015, 05:01 AM.
Working...
X