| |
Fragen und Antworten zur vbarchiv.dllRe: FTP Upload - Code-Sample (mit Fehlerbehandlung) | | | Autor: MSeuling | Datum: 05.09.06 21:05 |
| Hallo,
hier also...
die Deklaration:
'FTP Upload
Public Declare Function ftpConnect Lib "vbarchiv.dll" _
(sServer As String, _
sUser As String, _
sPW As String) As Long
Public Declare Function ftpPutFile Lib "vbarchiv.dll" _
(ByVal hSocket As Long, _
ByRef sServer As String, _
ByVal hStatus As Long, _
remoteFile As String, _
localFile As String) As Long
Public Declare Function ftpGetLastStatusCode Lib "vbarchiv.dll" _
() As Long
Public Declare Sub ftpSetAscii Lib "vbarchiv.dll" _
(ByVal hSocket As Long)
Public Declare Sub ftpQuit Lib "vbarchiv.dll" _
(ByVal hSocket As Long)
Und hier der eigentliche Code:
Sub FTPUpload()
'Lädt eine Text-Datei auf den Server. /public/... ist der Pfad ab dem Root
Dim pSocket As Long
Dim res As Long
Const cMyServer = "xyz.de"
pSocket = ftpConnect(cMyServer, "Benutzer", "Paßwort")
If pSocket > 0 Then
'OK: Verbindung geöffnet
ftpSetAscii (pSocket)
res = ftpGetLastStatusCode()
If res = 200 Then
'OK
res = ftpPutFile(pSocket, cMyServer, 0, "/html/catalog/wip/categories.csv", "G:\MS - MultimediaService\Wippermann\Artikeldatenbank\_Aktuell\To Import\categories.csv")
res = ftpPutFile(pSocket, cMyServer, 0, "/html/catalog/wip/categories_description.csv", "G:\MS - MultimediaService\Wippermann\Artikeldatenbank\_Aktuell\To Import\categories_description.csv")
res = ftpPutFile(pSocket, cMyServer, 0, "/html/catalog/wip/products_description.csv", "G:\MS - MultimediaService\Wippermann\Artikeldatenbank\_Aktuell\To Import\products_description.csv")
res = ftpPutFile(pSocket, cMyServer, 0, "/html/catalog/wip/products.csv", "G:\MS - MultimediaService\Wippermann\Artikeldatenbank\_Aktuell\To Import\products.csv")
res = ftpPutFile(pSocket, cMyServer, 0, "/html/catalog/wip/products_to_cat.csv", "G:\MS - MultimediaService\Wippermann\Artikeldatenbank\_Aktuell\To Import\products_to_cat.csv")
If res = 1 Then
'OK
ftpQuit (pSocket)
res = ftpGetLastStatusCode()
If res = 221 Then
'OK
ElseIf res = 0 Then
'nach ca. 45s
MsgBox "Problem bei FTP-Upload (ftpQuit): " & pSocket & "(keine Verbindung zu Server)"
Else
MsgBox "Problem bei FTP-Upload (ftpQuit)" & pSocket & "(unbekanntes Problem)"
End If
ElseIf res = 0 Then
'nach ca. 120s
MsgBox "Problem bei FTP-Upload (ftpPutFile): " & res & "(keine Verbindung zu Server)"
Else
MsgBox "Problem bei FTP-Upload (ftpPutFile): " & res & "(unbekanntes Problem)"
End If
ElseIf res = 0 Then
'Timeout nach 60s
MsgBox "Problem bei FTP-Upload (ftpSetAscii): " & res & "(keine Verbindung zu Server)"
Else
MsgBox "Problem bei FTP-Upload (ftpSetAscii): " & res & "(unbekanntes Problem)"
End If
ElseIf pSocket = -2147483648# Then
'nach ca 15s
MsgBox "Problem bei FTP-Upload FTP-Upload (ftpConnect): " & pSocket & "(keine Verbindung zu Server)"
Else
MsgBox "Problem bei FTP-Upload (ftpConnect)" & pSocket & "(unbekanntes Problem)"
End If
Set wshshell = CreateObject("WScript.Shell")
wshshell.Run "www.ms-multimediastore.de/catalog/wip/auto.php"
End Sub
In der Zeile: ElseIf pSocket = -2147483648# Then bleibt er dann stehen. Hab den Wert schon hin und her geändert, ohne irgendeine Auswirkung...
mfg Markus | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
Neu! sevCommand 4.0
Professionelle Schaltflächen im modernen Design!
Mit nur wenigen Mausklicks statten auch Sie Ihre Anwendungen ab sofort mit grafischen Schaltflächen im modernen Look & Feel aus (WinXP, Office, Vista oder auch Windows 8), inkl. große Symbolbibliothek. Weitere InfosTipp des Monats Access-Tools Vol.1
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
Copyright ©2000-2024 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|