Hier gehts weiter sonst währe die Nachricht zu Lang...
Const FILE_ATTRIBUTE_OFFLINE As Short = &H1000S
Private Structure FILETIME
Dim dwLowDateTime As Integer
Dim dwHighDateTime As Integer
End Structure
Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As Integer
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As Integer
Dim nFileSizeLow As Integer
Dim dwReserved0 As Integer
Dim dwReserved1 As Integer
<VBFixedString(MAX_PATH), System.Runtime.InteropServices.MarshalAs( _
System.Runtime.InteropServices.UnmanagedType.ByValTStr, _
SizeConst:=MAX_PATH)> Public cFileName As String
<VBFixedString(14), System.Runtime.InteropServices.MarshalAs( _
System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=14)> _
Public cAlternate As String
End Structure
Dim Verbundenoderwas As Boolean
Private Structure SYSTEMTIME
Dim wYear As Short
Dim wMonth As Short
Dim wDayOfWeek As Short
Dim wDay As Short
Dim wHour As Short
Dim wMinute As Short
Dim wSecond As Short
Dim wMilliseconds As Short
End Structure
Const FTP_UAgent As String = "FTP Demo"
Public Function SendFile(ByVal hFtpSession As Integer, ByVal lpszLocalFile As _
String, ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal _
dwContext As Integer) As Object
SendFile = FtpPutFile(hFtpSession, lpszLocalFile, lpszRemoteFile, dwFlags, _
dwContext)
End Function
Public Function GetFile(ByVal hFtpSession As Integer, ByVal lpszRemoteFile As _
String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal _
dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As _
Integer) As Object
GetFile = FtpGetFile(hFtpSession, lpszRemoteFile, lpszNewFile, fFailIfExists, _
dwFlagsAndAttributes, dwFlags, dwContext)
End Function
Public Function ConnectFTP(ByVal hInternetSession As Integer, ByVal _
sServerName As String, ByVal nServerPort As Short, ByVal sUsername As _
String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags _
As Integer, ByVal lContext As Integer) As Object
ConnectFTP = InternetConnect(hInternetSession, sServerName, nServerPort, _
sUsername, sPassword, lService, lFlags, lContext)
End Function
Public Function ConnectInternet(ByVal sAgent As String, ByVal lAccessType As _
Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal _
lFlags As Integer) As Object
ConnectInternet = InternetOpen(sAgent, lAccessType, sProxyName, sProxyBypass, _
lFlags)
End Function
Public Function CloseFTP(ByVal hInet As Integer) As Object
CloseFTP = InternetCloseHandle(hInet)
End Function
Public Function GoToSubDir(ByVal hFtpSession As Integer, ByVal lpszDirectory _
As String) As Object
GoToSubDir = FtpSetCurrentDirectory(hFtpSession, lpszDirectory)
End Function
End Class
End Class
'Form1
Dim nFlag As Integer
Dim result As Integer
hOpen = ftp.ConnectInternet("FTP", 1, vbNullString, vbNullString, 0)
If hOpen = 0 Then
MsgBox("Es konnte keine Verbindung hergestellt werden!", MsgBoxStyle.Critical, _
"Fehler")
Exit Sub
End If
hConnection = ftp.ConnectFTP(hOpen, Server, 0, User, Passwort, 1, nFlag, 0)
If hConnection = 0 Then
MsgBox("Es konnte keine Verbindung zum Server hergestellt werden. Überprüfen" & _
"Sie Ihre Daten")
Exit Sub
End If
Dim file As String
Dim result0 As Object
For Each file In ListBox2.Items
result0 = ftp.SendFile(hConnection, Environment.CurrentDirectory & "temp\" & _
file, file, &H0S, 0)
Dim Bild As New IO.FileInfo(programmPfad & "\temp\" & file)
Bild.Delete()
If result = 0 Then
MsgBox("Eine der Dateien konnte nicht Hochgeladen werden!", _
MsgBoxStyle.Critical, "Fehler")
End If
Next
ListBox2.Items.Clear()
If hConnection <> 0 Then ftp.CloseFTP(hConnection)
If hOpen <> 0 Then ftp.CloseFTP(hOpen) |