Teman2 saya punya coding sebagai berikut:
Ini merupakan potongan coding buat ngirim single file.
Saya ingin bertanya sama temen2 semua, bagaimana caranya
Ngirim beberapa file sekaligus??
Jadi file yang mw dikirim, ditampilkan dulu di form nya
(saat ini saya coba tampung di filelistbox) Cuma belum berhasil ngirim.
Saya udah cari di web, tp kebanyakan yang ada Cuma pengiriman single file.
Terimakasih sebelumnya.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''
Option Explicit
Private bSendingFile As Boolean
Private lTotal As Long
Public counter As Double
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command2_Click()
Dim o As Integer
Dim txtSaveAs As String
Dim temp As String
txtSaveAs ="D:\abc.jpeg"
For o = 1 To File1.ListIndex
temp = File1.List(o)
SendData temp, txtSaveAs, Winsock1
Next o
MsgBox "File terkirim dengan baik", vbOKOnly, "Kirim Files"
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''
Public Sub SendData(sFile As String, sSaveAs As String, tcpCtl As Winsock)
On Error GoTo ErrHandler
Dim sSend As String, sBuf As String
Dim ifreefile As Integer
Dim lRead As Long, lLen As Long, lThisRead As Long, lLastRead As Long
ifreefile = FreeFile
' Open file for binary access:
Open sFile For Binary Access Read As #ifreefile
lLen = LOF(ifreefile)
' Loop through the file, loading it up in chunks of 64k:
Do While lRead < lLen
lThisRead = 65536
If lThisRead + lRead > lLen Then
lThisRead = lLen - lRead
End If
If Not lThisRead = lLastRead Then
sBuf = Space$(lThisRead)
End If
Get #ifreefile, , sBuf
lRead = lRead + lThisRead
sSend = sSend & sBuf
Loop
lTotal = lLen
Close ifreefile
bSendingFile = True
'// Send the file notification
tcpCtl.SendData "FILE" & sSaveAs
DoEvents
'// Send the file
tcpCtl.SendData sSend
DoEvents
'// Finished
tcpCtl.SendData "FILEEND"
bSendingFile = False
Exit Sub
ErrHandler:
MsgBox "Err " & Err & " : " & Error
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''