Imports System.IO
Imports System
Imports System.Net
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub UploadFile(ByVal fileName As String, ByVal data As Stream)
Dim ub As New UriBuilder("http://localhost:3840/receiver.ashx")
ub.Query = String.Format("filename={0}", fileName)
Dim c As New WebClient
c.OpenWriteCompleted += Function(sender, e) Do
PushData(data, e.Result)
e.Result.Close()
data.Close()
End Sub
c.OpenWriteAsync(ub.Uri)
End Sub
Private Sub PushData(ByVal input As Stream, ByVal output As Stream)
Dim buffer As Byte() = New Byte(4095) {}
Dim bytesRead As Integer
While (InlineAssignHelper(bytesRead, input.Read(buffer, 0, buffer.Length))) <> 0
output.Write(buffer, 0, bytesRead)
End While
End Sub
End Class
|