Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim DATI As String
Dim s() As String
Winsock2.GetData DATI
s = Split(DATI, "|")
Select Case s(0)
Case "GETFILE"
Open PASDA For Binary As #5
Case "RIC"
IsReceived = True
Case "END"
Close #5
DoEvents
Case Else
Put #5, , DATI
DoEvents
Winsock2.SendData "RIC|"
ProgressBar1.Value = ProgressBar1.Value + 1
End Select
End Sub
Public Function SendFile(NomeFile As String) As Boolean
On Error GoTo errore
Dim bytBuf() As Byte
Dim z As Integer
z = FreeFile
ByteNow = 0
'FILE|PERCORSO|DIMENSIONE
Winsock2.SendData "GETFILE|" & NomeFile & "|" & CStr(FileLen(txtTrasfFile.Text))
DoEvents
Open txtTrasfFile.Text For Binary As #z
ReDim bytBuf(1 To 4096) As Byte
Do Until (FileLen(txtTrasfFile.Text) - ByteNow) < 4096
DoEvents
Get #z, ByteNow + 1, bytBuf()
ByteNow = ByteNow + 4096
DoEvents
IsReceived = False
Winsock2.SendData bytBuf
While IsReceived = False
DoEvents
Wend
Loop
Dim LastChunkSize As Long
LastChunkSize = FileLen(txtTrasfFile.Text) - ByteNow
DoEvents
ReDim bytBuf(1 To LastChunkSize) As Byte
Get #z, ByteNow + 1, bytBuf()
ByteNow = ByteNow + LastChunkSize
DoEvents
IsReceived = False
Winsock2.SendData bytBuf
While IsReceived = False
DoEvents
Wend
Close #z
DoEvents
Winsock2.SendData "END|"
DoEvents
Exit Function
SendFile = True
errore:
End Function
Che ne dite io l'ho provato e funziona, o meglio i file me li trasferisce a parte quella seccatura della chiusura
Un altro problema è sorto un con file pdf di 39 kb nn ne vuole sapere di inviarlo è l0unico file che nn riesco ad inviare, ho inviato file da 2 kb fino a 50mb e tutto ok ma cn questo di 39kb nada
UFFA!