Sending Binary files with a TCP/IP Communication
I have a rather 'small' peice of code I found on the newsgroups earlier last
month.
Here you go, asumming you have a connection established with computer A & B,
then it should work like a breeze for you...
Good Luck!
'------------------
'Computer A
'-------------------
'Here you go
'This code assums you have a control named WinSock1
Dim FileNum As Integer
Dim baSendFile() As Byte
FileNum = FreeFile
'Here you need to specify the file being sent
'It would work good with a Common Dialog control
'So the End user can pick the file he/she wants to send
Open "Your.Filename" For Binary As FileNum
ReDim baSendFile(1 To LOF(FileNum))
Get #FileNum, 1, baSendFile
Close FileNum
Winsock1.SendData baSendFile()
MsgBox "File Transfer Complete!"
'------------------
'Computer B
'-------------------
'Here you go
'This code assums you have a control named WinSock2
'You should put this on a different form?
Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim FileNum As Integer
Dim baRecv() As Byte
ReDim baRecv(1 To bytesTotal)
Winsock2.GetData baRecv, vbByte, bytesTotal
FileNum = FreeFile
'This is the file where the data should be wrote to.
'You could somehow extract the filename and put a string there
'With the right name
Open "Incoming.FileName" For Binary As FreeFile
Put #FileNum, LOF(FileNum) + 1, baRecv
Close FileNum
MsgBox "File Transfer Complete!"
End Sub
Good Luck with your app!
--
Ricky
Ricky Harjes - TSCL
"Real programmers are those that can
sleep in front of terminals ... with their
eyes opened." - Anonymous
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Quote:
>Hello All !!!
>How I send a binary file from Computer A to Computer B, the Computer A and
>the Computer B are conected to the internet, I would like what my
>application send a binary file from computer A to Computer B. How I make
>this ??
>Excuse-me, if my english is incorrect, because I am brazilian.
>Thanks.
>Thanks.
>Thanks.
begin 666 Ricky S. Harjes.vcf
M1#TP00T*0412.TA/344Z.SL[.TU.#0I,04)%3#M(3TU%.DU.#0I54DPZ:'1T
M<#HO+W=W=RYG96]C:71I97,N8V]M+WYH;W=D>0T*55),.FAT=' Z+R]W=W<N
M9V5O8VET:65S+F-O;2]^:&]W9'D-"D5-04E,.U!2148[24Y415).150Z:VAA
"#0H`
`
end