deusfalsus
Erfahrenes Mitglied
Hallo,
ich möchte die Dateien eines Ordner per ftp an einen bestimmten Ort bringen.
Um sicher zu gehen, dass auch alle ankommen, möchte ich jede einzeln rüberschieben und die Antwort auswerten.
Den Output auf die Console zu schreiben mache ich nur temporär zum Testen. Eigentlich will ich diesen ja auswerten. Aber mal klappt es nur zeilenweise den Output zu lesen (also mit .readline) und mal zeichenweise.
Vom Input kommt wie es scheint immer nur der erst an.
Folgender Ansatz klappt leider nicht:
ich möchte die Dateien eines Ordner per ftp an einen bestimmten Ort bringen.
Um sicher zu gehen, dass auch alle ankommen, möchte ich jede einzeln rüberschieben und die Antwort auswerten.
Den Output auf die Console zu schreiben mache ich nur temporär zum Testen. Eigentlich will ich diesen ja auswerten. Aber mal klappt es nur zeilenweise den Output zu lesen (also mit .readline) und mal zeichenweise.
Vom Input kommt wie es scheint immer nur der erst an.
Folgender Ansatz klappt leider nicht:
Code:
Function ftp(ByVal quelle As String, ByVal ziel As String, ByVal server As String, ByVal user As String, ByVal pass As String, ByVal logfile As String)
Try
Dim subProz As New System.Diagnostics.Process
With subProz.StartInfo
.FileName = "ftp.exe"
.CreateNoWindow = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.UseShellExecute = False
End With
logfile_Eintrag(logfile, "Starte FTP-Prozess")
subProz.Start()
Dim ProzessOutput As System.IO.StreamReader = subProz.StandardOutput
Dim ProzessInput As System.IO.StreamWriter = subProz.StandardInput
ProzessInput.AutoFlush = True
Dim Output As String
While ProzessOutput.Peek <> -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine("open " & server)
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine(user)
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine(pass)
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine("binary")
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine("prompt")
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
subProz.StandardInput.WriteLine("cd """ & ziel & """")
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
For Each datei As String In IO.Directory.GetFiles(quelle)
subProz.StandardInput.WriteLine("put """ & quelle & """")
While ProzessOutput.Peek > -1
Output = ProzessOutput.Read
Console.Write(Chr(Output))
End While
Next
subProz.StandardInput.WriteLine("bye")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return 0
End Function
Zuletzt bearbeitet: