我想用vb6.0做个文件传送程序,使用tcp协议,用二进制方式读写文件,可是我用winsock的getdata方法来接收文件,则接收到的exe文件会没有用,文本文件则有用,且数据完整,如果我用winsock的peekdata方法接收文件,则接收到的文本文件会没有用,全部显示为乱码,而exe文件则有用,请问这是为什么?(请问有人有这方面的例子吗,如果有,麻烦上传来看看)谢谢
解决方案 »
- 救急救急~~~哪位高手帮我看一下这段代码啊,谢谢.
- 关于label的字体大小自动调整.
- 看到一个好贴,转一下
- vb6.0 怎样实现鼠标滚动操作
- 在Acess数据库中MDE文件是干什么的?如何打开?
- VB怎样实现像IE浏览器那样的拆分窗口??
- “连接本机的15001,一次性传送所有超标数据”,这个是什么意思????
- 各位高手,请教B/S模式!
- 这个程序怎样在不满足条件的时候不打开excel,msgbox显示没有您要找的数据
- sql语句模糊查询的问题acess数据库!??????急
- [看来10ms定时器对于VB真的有点不太现实啊...]偶然发现一个问题,导致10ms的定时器程序并不稳定。。。
- 请问如何将文件传送程序发送的文件分开来发送?????
'将文件读到字节数组并发送出去
Dim oFSD As FileSystemObject
Dim strError As String
Dim oText As TextStream
Dim aa() As Byte, array1() As Byte
Dim i As Long, l As Long
Dim Location, bb As String
On Error Resume Next
i = 0
l = 0
Open sFile For Binary Access Read Lock Read As #1
Do While Location < LOF(1)
ReDim Preserve array1(i)
aa() = InputB(1, #1)
Location = Loc(1)
array1(l) = aa(0)
l = l + 1
i = i + 1
DoEvents
Loop
'Debug.Print "l:"; l
Close #1
bolSend = False
'TcpUser.SendData array1()
winsockUser.SendData array1()
Do Until bolSend
DoEvents
Loop
'MsgBox "文件发送完毕!"
End Sub
'将字节数组中的数据写到文件中
Dim oFSD As FileSystemObject
Dim strError As String
Dim loca, locab
Dim sFile As String
Dim fPath As String
Dim bolFindIp As Boolean
Dim i As Long, j As Long
Dim pDwName As String
On Error Resume Next
sFile = mfile
Open mfile For Binary Access Read Write As #2
If LOF(2) = 0 Then
loca = 1
Else
loca = LOF(2) + 1
End If
Seek #2, loca
Put #2, , fdata()
locab = LOF(2)
If mfile_len = locab Then
For i = 0 To UBound(FileArr(), 1)
If FileArr(i, 5) = mfile Then
pDwName = FileArr(i, 6)
bolFindIp = True
Exit For
End If
Next
If bolFindIp Then
fPath = Left(FileArr(i, 4), Len(FileArr(i, 4)) - 1)
sFile = FileArr(i, 2)
For j = 0 To UBound(FileArr(), 2)
FileArr(i, j) = ""
Next
End If
Close #2
If sFile = "每日数据" Or sFile = "实时信息" Or sFile = "日数据" Then Call SetTabel(sFile, fPath, pDwName)
'MsgBox "文件" & mfile & "接收完毕!"
Else
Close #2
End If
End Sub