1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Dim tst2
'stocke le repertoire racine
sOrgPath = String(MAX_PATH, 0)
'obtien le repertoire
FtpGetCurrentDirectory hConnection, sOrgPath, Len(sOrgPath)
FtpSetCurrentDirectory hConnection, sSource
pData.cFileName = String(MAX_PATH, 0)
hFind = FtpFindFirstFile(hConnection, "*.*", pData, 0, 0)
nLastError = Err.LastDllError
If hFind = 0 Then
If (nLastError = ERROR_NO_MORE_FILES) Then
MsgBox "Le répertoire défini sur le FTP est vide !", vbOKOnly, "Alerte"
End If
Exit Function
Else
Dim bRet As Boolean
Dim strItemName As String
strItemName = Left(pData.cFileName, InStr(1, pData.cFileName, String(1, 0), vbBinaryCompare) - 1)
tst2 = FtpGetFile(hConnection, sSource & strItemName, sDest & strItemName, False, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0)
Do
pData.cFileName = String(MAX_PATH, 0)
bRet = InternetFindNextFile(hFind, pData)
If Not bRet Then
dError = Err.LastDllError
Exit Do
Else
strItemName = Left(pData.cFileName, InStr(1, pData.cFileName, String(1, 0), vbBinaryCompare) - 1)
tst2 = FtpGetFile(hConnection, sSource, sDest & strItemName, False, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0)
End If
Loop
End If |
Partager