I have created a program that uses tcp/ip sockets to communicate between the client and server. I am looking for a way to send a file to the server over this connection that already exists. I understand that a network stream will have to be used. I found this code on another post written by Atheist, that will send the contents of the file through the network stream. I think that will work.As for the part that im not sure of, is what do i have to do to recieve the file on the server side? Maybe somebody could supply come code for piecing the file back together. Another things that would be useful would be a list of procedure that needs to be followed to get the transfer to work. as of right now I haveCode:Dim sendBuffer(1023) As Byte Dim fileToSend As String = "c:\somePicture.jpg" Dim fStream As System.IO.FileStream Dim bytesRead As Integer = 0 If System.IO.File.Exists(fileToSend) Then fStream = New System.IO.FileStream(fileToSend, IO.FileMode.Open) Do bytesRead = fStream.Read(sendBuffer, 0, 1024) If bytesRead > 0 Then nStream.Write(sendBuffer, 0, bytesRead) 'Where nStream is the NetworkStream for the connection End If Loop While bytesRead > 0 End If
Client:
1.get file path
2.read file into pieces
3.send each piece
Server:
4.read each piece
5. assemble back into a file
Thanks for the help. -Adam




Reply With Quote