The program crashes without an error message and stops on the line 17 Resp.OutputStream.WriteBytes(Buf, 0, Buf.Length - 1)
I need help finding the fault, which is not even visible?
Clientcode:
I need help finding the fault, which is not even visible?
Handle:
'Handler class
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim filename As String = req.GetParameter("Filename")
Dim Dir As String = req.GetParameter("Dir")
Dim Buf() As Byte
If File.Exists(Dir, filename) Then
Buf = File.ReadBytes(Dir, filename)
resp.SetHeader( "Content-Disposition", "attachment; filename=" & filename)
resp.OutputStream.WriteBytes(Buf, 0, Buf.Length - 1)' [B]get out, no error message, complete stop[/B]
Else
resp.SendError(404, "File not found")
End If
End Sub
Clientcode:
GetPicture:
Sub GetPicture (sdir As String, sImg As String)
Dim sLink As String = "http://MyComputer.duckdns.org:54021/Download"
Dim jobDownload As HttpJob
jobDownload.Initialize( "jobDownload", Me)
jobDownload.PostString( sLink, "?Operation=DownloadImageFile&Dir=" & sdir & "&Filename=" & sImg & "&UserID=" & PG_UserID)
Wait For (jobDownload) JobDone(jobDownload As HttpJob)
If jobDownload.Success Then
Dim in As InputStream
Dim Out As OutputStream
Dim sDirDL As String = "\\Localhost\C\Users\name\Media\Uploads"
Out.InitializeToBytesArray(0)
in = jobDownload.GetInputStream
Out = File.Openoutput( sDirDL, sImg, False)
File.Copy2(in, Out)
End If
End Sub