分要多少我全给也行!

解决方案 »

  1.   

    发送端:Public Function SendChunk()
      'This is where we send the file data
      Dim ChunkSize As Long
      Dim Chunk() As Byte
      Dim arrHash() As Byte
      
      If wsSend.State <> sckConnected Then Exit Function
      
      ChunkSize = FT_BUFFER_SIZE '自己定
      If FileNum = 0 Then 'No data has been sent yet, open the file
        FileNum = FreeFile
        Open filename For Binary As #FileNum
      End If
      
      'determine chunk size
      If (LOF(FileNum) - Loc(FileNum)) < FT_BUFFER_SIZE Then _
         ChunkSize = (LOF(FileNum) - Loc(FileNum))
      'set array size to fit chunk
      ReDim Chunk(0 To ChunkSize - 1)
      'read the chunk
      Get #FileNum, , Chunk
      'Send the data
      wsSend.SendData Chunk
      Sentbyt = Sentbyt + ChunkSize
      ByteSec = ByteSec + ChunkSize
      
      'See if file is sent
      If Sentbyt = FileSize Then 'FileSize自己先找好
        Complete = True
        Close #FileNum
      End If
    End Function
    接收端:Open Filename For Binary As #FileNumDim GotDat() As Byte
    Dim Hash As String
    ByteSec = ByteSec + bytesTotal
    Receivedbyt = Receivedbyt + bytesTotalReDim GotDat(0 To bytesTotal - 1)
    wsReceive.GetData GotDat, vbArray + vbByte
    Put #FileNum, , GotDat
    If Receivedbyt = FileSize Then
    Close #FileNum
    Complete = True
    End If
    不明白就来mail,  [email protected]