i said previously that i would send you the code that i have in my application to send files, however i wrote this to send only text files, its not the best method but i worked for what i needed it for, i got some help online but i cannot find the link i used, it was a few years back now, anyways i hope this helps im not sure how it will display when i copy paste it, if you want the app i wrote (test version) i would be more than happy to email it to anyone that wants it..
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
'When data is recived we must first identify what type of data it is.
Private Sub CheckDataType()
'there are two types of data that can be recivied a file, or an error message.
If Left(TheData, 6) = "Error:" Then
Recivedata App.Path & "\" & Text2.Text & ".txt", TheData
'this is used by the DataAlrrival in the previous form
Public Sub Recivedata(FileNametoSave As String, Data)
FreeFileNumber = FreeFile ' assigsn a filenumber to YOUR file
'Check to see if the file is already open
Open FileNametoSave For Binary Access Write As #FreeFileNumber
'transfer data to another variable to be manipulated
temp = Data
'Check to see if it is the end of the transmition
'If it is the end, it will close the file
'You may also add different cases here for under functions
If temp = "end" Then
FileRequest = False
CheckFileAva = False
MsgBox "Transfer Success"
Put #FreeFileNumber, , temp
Private Sub Winsock1_DataArrival(index As Integer, ByVal bytesTotal As Long)
'server ONLY accepts the clients computer name (which must begin with "Name")
'AND the log file but only if it was requested.
Dim TheData As String
ClientIndex = index 'This identifies WHO requested the file.
FileRequested = (TheData & ".txt")
Private Sub SearchFile(FileName As String)
'This function recivies that filename as a argument and then searches it current
'directory to see it that file exists.
'if not then an error report is send else the file is sent.
Dim FileSystem, FindFile
Set FileSystem = CreateObject("Scripting.FileSystemObject")
FindFile = FileSystem.FileExists(App.Path & "\" & FileName)
If FindFile = True Then
SendFile (App.Path & "\" & FileName)
If FindFile = False Then
I hope this is enough for you to understand what i was doing, basically the client and server must establish a connection a you know, multiple clients can connect to the server, when a client requests a file the server will check who requested it and send the file, one thing to note is that in some of my apps what i do is prefix the request with a symbol or a sequence so that when the server recieves the request it can determine what the client is asking.
Hope this helps.