tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
1
ZUGRIFFE
475
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Avatar von deusfalsus
    deusfalsus deusfalsus ist offline Mitglied Brokat
    Registriert seit
    Jan 2003
    Ort
    Jena (Thüringen)
    Beiträge
    254
    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:
    Code :
    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
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    
    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
    Geändert von deusfalsus (07.12.10 um 12:04 Uhr)
     

  2. #2
    tequila slammer tequila slammer ist offline Mitglied Gold
    Registriert seit
    Aug 2006
    Beiträge
    204
    Schau mal im Netz. Es gibt genug frei ftp-Libs. So brauchst du dich nicht mit den Outputs andere Software beschäftigen. Niemand wird dir sagen können ob es an deinem Code oder an der ftp.exe liegt.
     

Ähnliche Themen

  1. WLAN Datentransport über C++ und USB WLAN
    Von IWANTTOGOINTHERE im Forum C/C++
    Antworten: 7
    Letzter Beitrag: 12.09.08, 15:17