hi!

1# when receiving a file you should only open it one time
2# g_PutByte = g_PutByte + bytesTotal so that you start writing at the end of the new file.
3# when all of the bytes is reveived then close the file.


to know the size of the file you must get the file size on the client
side and send it to the server ( this is how I did it, maybe there is a better way )

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData dat, vbString
If received = 1 Then
WF = FreeFile
Open WF_filepath For Binary As #WF 'How do you get the file path from the server?
Put #WF, received, dat
received = received + Len(dat)
If received >= LOF(dat) Then 'How do you get to file size from the server?
Close #WF
End If
End If
End Sub
in your example you only open the file and put tada in it if received = 1 you must put the data in the new file on every
DataArrival.

ex:
1# Put #WF, 1, dat
2# Put #WF, 4097, dat
3# Put #wf, 8193, dat
untill the whole file is received.