Results 1 to 3 of 3

Thread: question on this function i found

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    question on this function i found

    VB Code:
    1. Public Sub SendFile(SocketObject As Variant, ByVal FilePath As String, ByVal PacketSize As Long)
    2.     Dim lonFF As Long, bytData() As Byte
    3.     Dim lonCurByte As Long, lonSize As Long
    4.     Dim lonPrevSize As Long
    5.    
    6.     On Error GoTo ErrorHandler
    7.    
    8.     lonSize = FileLen(FilePath)
    9.    
    10.     Open FilePath For Binary Access Read As #lonFF
    11.        
    12.         ReDim bytData(1 To PacketSize) As Byte
    13.        
    14.         Do Until (lonSize - lonCurByte) < PacketSize
    15.             Get #lonFF, lonCurByte + 1, bytData()
    16.             lonCurByte = lonCurByte + PacketSize
    17.             SocketObject.SendData bytData()
    18.             DoEvents
    19.         Loop
    20.        
    21.         lonPrevSize = lonSize - lonCurByte
    22.        
    23.         If lonPrevSize > 0 Then
    24.             ReDim bytData(1 To lonPrevSize) As Byte
    25.             Get #lonFF, lonCurByte + 1, bytData()
    26.             lonCurByte = lonCurByte + lonPrevSize
    27.             SocketObject.SendData bytData()
    28.         End If
    29.    
    30.     Close #lonFF
    31.     Exit Sub
    32.    
    33. ErrorHandler:
    34.         Debug.Print "Send File Error"
    35.         Debug.Print "---------------"
    36.         Debug.Print "Number:      " & Err.Number
    37.         Debug.Print "Description: " & Err.Description
    38.         Debug.Print "File:        " & FilePath
    39.    
    40. 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
    Last edited by Pouncer; Dec 3rd, 2005 at 05:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width