In vb2005 how do you simulate a web browser's file download using Net.HttpListener?
This current program functions somewhat like a webserver. how when a client from a web browser asks for a file do i allow them to down load the file? currently the method will tell the browser that there is a file but it will fail after the client oks the file for download. below is the code im trying to use
Dim fname As New IO.FileInfo(cuser.Request.QueryString(itm))
hedlst.Add(Net.HttpRequestHeader.ContentType, "application/octet-stream")
hedlst.Add(Net.HttpRequestHeader.ContentEncoding, "UTF-8")
hedlst.Add("Content-Disposition", "attachment;filename=""" & fname.Name & """")
cuser.Response.ContentEncoding = System.Text.Encoding.UTF8
Me.Invoke(xnl, uname & " begining download of file : " & fname.FullName)
writeoutstream(cuser.Response, fname.OpenRead, hedlst)
Me.Invoke(xnl, uname & " downloaded file : " & fname.FullName)
Private Sub writeoutstream(ByRef uret As Net.HttpListenerResponse, ByRef outtxt As IO.Stream, ByVal headers As System.Net.WebHeaderCollection)
uret.SendChunked = True
uret.Headers = headers
outtxt.Position = 0
Dim cnl(outtxt.Length) As Byte
outtxt.Read(cnl, 0, cnl.Length)
uret.OutputStream.Write(cnl, 0, cnl.Length)
cnl = Nothing
outtxt.Dispose()
End Sub