Transferring a file can be as simple as reading data from one stream, and writing it to another. Using this code:
CODE
Public Sub TransferData(FromStream As IO.Stream, ToStream As IO.Stream, BufferSize As Integer)
Dim buffer(BufferSize - 1) As Byte
Do While True
Dim bytesRead As Integer = FromStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then Exit Do
ToStream.Write(buffer, 0, bytesRead)
Loop
End Sub
For example, to transfer a file through a network using a Socket, you can create a new NetworkStream which incapsulates the socket. Using the code I posted above, pass a FileStream to the FromStream parameter, and pass the NetworkStream to the ToStream parameter. BufferSize can be 1024 (1 KB).
Hope this helps you out.
- Andrew
This post has been edited by whisla13: 22 May, 2007 - 09:46 AM