VB Code:
  1. if System.IO.File.Exists(Server.MapPath("createdfiles/woof.txt")) Then
  2.  
  3.         Dim TargetFile As New System.IO.FileInfo(Server.MapPath("createdfiles/woof.txt"))
  4.  
  5.         ' clear the current output content from the buffer
  6.         Response.Clear()
  7.         ' add the header that specifies the default filename for the Download/
  8.         ' SaveAs dialog
  9.         Response.AddHeader("Content-Disposition", "attachment; filename=" + _
  10.             TargetFile.Name)
  11.         ' add the header that specifies the file size, so that the browser
  12.         ' can show the download progress
  13.         Response.AddHeader("Content-Length", TargetFile.Length.ToString())
  14.         ' specify that the response is a stream that cannot be read by the
  15.         ' client and must be downloaded
  16.         Response.ContentType = "application/octet-stream"
  17.         ' send the file stream to the client
  18.         Response.WriteFile(TargetFile.FullName)
  19.         ' stop the execution of this page
  20.         Response.End()
  21.  
  22. End If