这是我看到的一个程序里的部分代码,用来传送文本文件没问题,可是传送别的就不行了,谁能给改改,谢谢
Public Sub SendFile(FileName As String, WinS As Winsock)Dim FreeF As Integer
Dim LenFile As Long
Dim nCnt As Long
Dim LocData As String
Dim LoopTimes As Long
Dim i As LongFreeF = FreeFileOpen FileName For Binary As #99nCnt = 1LenFile = LOF(99)WinS.SendData "|FILESIZE|" & LenFile
DoEventsSleep (400)
Do Until nCnt >= (LenFile)
LocData = Space$(1024) 'Set size of chunks
Get #99, nCnt, LocData 'Get data from the file nCnt is from where to start the get
If nCnt + 1024 > LenFile Then
WinS.SendData Mid$(LocData, 1, (LenFile - nCnt))
Else
WinS.SendData LocData 'Send the chunk
End If
nCnt = nCnt + 1024
Loop
Close #99End Sub
Public Sub SendFile(FileName As String, WinS As Winsock)Dim FreeF As Integer
Dim LenFile As Long
Dim nCnt As Long
Dim LocData As String
Dim LoopTimes As Long
Dim i As LongFreeF = FreeFileOpen FileName For Binary As #99nCnt = 1LenFile = LOF(99)WinS.SendData "|FILESIZE|" & LenFile
DoEventsSleep (400)
Do Until nCnt >= (LenFile)
LocData = Space$(1024) 'Set size of chunks
Get #99, nCnt, LocData 'Get data from the file nCnt is from where to start the get
If nCnt + 1024 > LenFile Then
WinS.SendData Mid$(LocData, 1, (LenFile - nCnt))
Else
WinS.SendData LocData 'Send the chunk
End If
nCnt = nCnt + 1024
Loop
Close #99End Sub
二进制文件读进来后会出现问题
open app.path & "\aaa.jpg" for binary as #1
get #1,,gbytSum
close #1
winsock1.senddata "aaa.jpg"
doevents
winsock1.senddata gbytSum
end sub收的时候先获取对方发过来的文件名"aaa.jpg"然后
open app.path & "\aaa.jpg" for binary as #1
打开文件,但暂不关闭,再获取文件内容,将文件内容同样读入一二进制数组中
再将二进制数组写入文件
put #1,,bytSum
全部写完后再关闭文件
close #1如果还有不明白的话,我可以做个例子发给你看
麻烦你发一个过来吧,谢谢了.明天看
Else ' 否则为图片内容
Put #1, , bytSum'这报错
End If