# Re: 利用winsocket互传档案的问题

Posted by 老怪 on September 10, 1998 at 23:32:41:

In Reply to: 利用winsocket互传档案的问题 posted by 阿信 on September 07, 1998 at 14:54:24:

: 我目前想利用两个winsock互(or单向)传档(ex:aa.bmp),
: 但是在开档之后(以binary mode开档),读出来的资料要以
: 何种格式储存在阵列?储存之后要如何送出(senddata?)

: 如蒙赐教,感激不尽力!!!

A.送二进位档案：
Dim FileHandle As Integer
Dim SendBuff() As Byte
FileHandle = FreeFile
Open "YourFilePathAndName" For Binary As #FileHandle
ReDim SendBuff(LOF(FileHandle) - 1)
Get #FileHandle, , SendBuff
Winsock1.SendData SendBuff

B.送二进位字串：
Dim SendBuff() As Byte
Dim SendString As String
SendString = "利用 WinSock.SendData 二进位方式送字串"
ReDim SendBuff(LenB(StrConv(SendString, vbFromUnicode)) - 1)
SendBuff = SendString
Winsock1.SendData SendBuff

Follow Ups: