VB如何分辨Winsock发过来的是消息还是文件
Private Sub Listen_DataArrival(Index As IntegerByVal bytesTotal As Long)Dim Data, b
Dim bytData() As Byte
Dim lLenFile As Long
Dim f, a
Listen.GetData Data
b = Time()
If Data = "212f15r5SDDD511b/',],[D4" Then
f = FreeFile
Open FileName For Binary As #f ''FileName是文件名
lLenFile = LOF(f)
ReDim bytData(1 To bytesTotal)
Listen.GetData bytData
Fil (FileName)
If a = 0 Then
MsgBox "文件已存在!"
Exit Sub
End If
If lLenFile = 0 Then 'lLenFile=0表示是第一次打开文件,这里有个问题,就是如果如果该文件存在的话,就会出错,应该在打开前检查文件是否存在
Put #f, 1, bytData
Else
Put #f, lLenFile + 1, bytData
End If
Close #f
End If
End Sub