VB Code:
Public Sub SendFile(SocketObject As Variant, ByVal FilePath As String, ByVal PacketSize As Long) Dim lonFF As Long, bytData() As Byte Dim lonCurByte As Long, lonSize As Long Dim lonPrevSize As Long On Error GoTo ErrorHandler lonSize = FileLen(FilePath) Open FilePath For Binary Access Read As #lonFF ReDim bytData(1 To PacketSize) As Byte Do Until (lonSize - lonCurByte) < PacketSize Get #lonFF, lonCurByte + 1, bytData() lonCurByte = lonCurByte + PacketSize SocketObject.SendData bytData() DoEvents Loop lonPrevSize = lonSize - lonCurByte If lonPrevSize > 0 Then ReDim bytData(1 To lonPrevSize) As Byte Get #lonFF, lonCurByte + 1, bytData() lonCurByte = lonCurByte + lonPrevSize SocketObject.SendData bytData() End If Close #lonFF Exit Sub ErrorHandler: Debug.Print "Send File Error" Debug.Print "---------------" Debug.Print "Number: " & Err.Number Debug.Print "Description: " & Err.Description Debug.Print "File: " & FilePath End Sub
so does this function only send the contents of the file?? not the actual file itself?
how can i end up viewing the file then if its a .png .html etc?
i want to be able to transfer files (rather than just file contents)between myself and another user thorugh a winsock connection




Reply With Quote