Hosting Knowledge ASP.Net - Code For File Download
SocialTwist Tell-a-Friend
Advertisement

ASP.Net - Code For File Download

Here is a code that actually download a file for your website visitor:

Dim fst As New FileStream(Server.MapPath("abc.txt"), FileMode.Open)
Dim fi As String
fi = "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)



Rate This Article


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
poorGreat

Recent Comments


9JlM6s , [url=http://gtjbxnoomezg.com/]gtjbxnoomezg[/url], [link=http://uanqefpjhnxy.com/]uanqefpjhnxy[/link], http://yhxreiyfpvmt.com/


Posted by : szwuizia Feb 4th, 2012

Pzx2R0 pmuawwqfhqxn


Posted by : hgvfnxkxm Feb 4th, 2012

FDfUSK , [url=http://xblbzzbvwlvn.com/]xblbzzbvwlvn[/url], [link=http://ozqacmnvnvvy.com/]ozqacmnvnvvy[/link], http://ezjiazpirhtr.com/


Posted by : mfzskdbvse Feb 3rd, 2012

BVYwex qqkzbaeunzjm


Posted by : oukmwdudutz Feb 3rd, 2012

Call me wind because I am absuoltely blown away.


Posted by : Cash Feb 2nd, 2012

Very useful and rare piece of information! Thanks.


Posted by : Veli Pehlivanov Apr 23rd, 2009

Great post, also, do not forget to end the response by adding the line \'Response.End()\' at the end of the code block. Otherwise the file will be appended with the entire page code.


Posted by : Eduardo Cabre Mar 19th, 2009

Add comment


  • Your name :
  • Email :
  • *Comment :
  • Word Verification

Web Hosting Directory

  • The web hosting directory is for anyone who is searching for website hosting and hosting related resources. The directory is listing Shared, VPS and Dadicated server plans in descending order for customer ratings !!! This web hosting directory is listing plans on the basis of 100% unbiased customer ratings. TheWebHostingDir.com provides you nice tool to easily search all types of web hosting plans including cheap web hosting, ASP.Net hosting, php mysql hosting, Cheap VPS Hosting, Windows VPS, HyperV VPS, Xen VPS and Cpanel VPS Hosting.



Quick search

Request a Quote

If you wish to receive proposals from Web Hosting Companies Suited to your needs.