In processing data specified on a page that allows the user to filter results from a database I write a tab-delimited text file of the data to a specific location on the server.
Following that, I show the data in a table to the user.
If they like what they see, I would like them to be able to download the file that was created.
I have a working app of this in VB6 / IIS, but now I want to do the same thing with VB
The code in the VB6 WebClass app was (this is a “Custom Web Item” in the WebClass designer):
Private Sub Send_File_Respond()
On Error GoTo E
Dim fSize As String: fSize = GetFileSize("\\the_server\the_path\file.ext")
Dim oStrm As ADODB.Stream: Set oStrm = New ADODB.Stream
Response.Buffer = True ' Turning on buffering and clearing ensures that
Response.Clear ' all of the header information will be at the
' top. Feature of IIS 4 and greater.
oStrm.Type = adTypeBinary
Response.AddHeader "Content-Disposition", "attachment; filename=file.ext"
Response.AddHeader "Content-Length", fSize
' The fol. value is found in registry at: HKEY_CLASSES_ROOT\MIME\Database\Content Type
Response.ContentType = "text/plain"
Response.Charset = "UTF-8"
Set oStrm = Nothing
R: Exit Sub
E: Dim eN As Long: eN = Err.Number
Dim eD As String: eD = Err.Description
SetCustomMessages Session, , , _
"Error " & eN & "<br>" & _
eD & "<br>" & _
Set NextItem = z__ErrorReport
How do I duplicate this behavior (puts a "Save" / "Open" dialog on top of Internet Explorer) but without the ADODB features, utilizing the resources of .NET?