Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[VB.NET] FTP Parameter NLST.

Empfohlene Antworten

Veröffentlicht

Hi,

ich schreib mir gerade eine kleine FTP Client Klasse, welche über die gängigsten Funktionen beinhalten soll.

Jedoch gestaltet sich der NLST Befehl als recht schwierig. Beziehungsweise das verständis dafür fehlt mir anscheinend, da die Response vom FTP Server Null ist.

Beschreibung des NLST und des PASV Befehls.

Ich hab mal die entsprechenden Zeile rausgesucht.

Das wäre demnach mein aktueller stand:


#Region "Fields"

    Private Const BUFFER_SIZE As Integer = 4090

    Private _Buffer(BUFFER_SIZE) As Byte

    Private enc As Encoding = Encoding.ASCII

    Private writer As StreamWriter = Nothing

    Private reader As StreamReader = Nothing

#End Region


 Public Sub NLST()

        WaitForResponse(writer)

        Dim s As Socket = Datasocket()

        writer.WriteLine("NLST" & vbCr & vbLf)

        WaitForResponse(reader)

        Dim response As String = String.Empty

        While True

            Dim retval As Integer = 0

            retval = reader.BaseStream.Read(_Buffer, 0, _Buffer.Length)

            response &= enc.GetString(_Buffer)

            If retval < BUFFER_SIZE Then

                Exit While

            End If

        End While

        ClearBuffer()

        MsgBox(response)

        response = String.Empty

        While True

            Dim retval As Integer = 0

            retval = s.Receive(_Buffer, 0, SocketFlags.None)

            response &= enc.GetString(_Buffer, 0, retval)

            If retval < BUFFER_SIZE Then

                Exit While

            End If

        End While


'Der response String sollte jetzt eigentlich

'die Dateinamen des aktuellen Verzeichnisses 

'per Carage Return Linefeed seperiert beinhalten.

        MsgBox(response)


        ClearBuffer()

    End Sub


 Public Function Datasocket() As Socket

        Dim s As Socket = Nothing

        WaitForResponse(writer)

        writer.WriteLine("PASV" & vbCr & vbLf)

        WaitForResponse(reader)

        Dim response As String = String.Empty

        While True

            Dim retval As Integer = 0

            retval = reader.BaseStream.Read(_Buffer, 0, _Buffer.Length)

            response &= enc.GetString(_Buffer)

            If retval < BUFFER_SIZE Then

                Exit While

            End If

        End While

        ClearBuffer()

        If response.Contains("227") Then

            Dim cache As String = response.Substring(response.IndexOf("(") + 1, response.LastIndexOf(")") - response.IndexOf("(") - 1)

            Dim fields As String() = Split(cache, ",")

            s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

            s.Connect(fields(0) & "." & fields(1) & "." & fields(2) & "." & fields(3), (fields(4) * 256) + fields(5))

        End If

        Return s

    End Function

Würde mich freuen, wenn mir jemand helfen könnte.

lg

Gateway

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.