FTP.ListDirectoryDetails / Unerklärlicher "Freeze" bei rekursivem Vorgehen

  • VB.NET

    FTP.ListDirectoryDetails / Unerklärlicher "Freeze" bei rekursivem Vorgehen

    Hallo,

    Ich versuche mich gerade in einem FTP-Client. Allerdings schiesst sich das Programm "ohne jegliche Erklärung" an einer bestimmten Stelle ab...
    Es gibt keine Exception, es ist kein Timeout, im Debug Modus hört der Code einfach an einer Stelle auf, und die App stuckt...

    Hier mal der code: Das ganze befindet sich in einer FTPConnector Klasse (die ich gerade schreibe) und _xxx sind private variablen:
    Die MSBoxen dienen zum "dirty debugging" :)

    Die Ordner Struktur des Servers sieht zunächst so aus:

    DIR Allgemein
    --> FILE test.txt
    DIR bnb
    --> DIR Ajax
    ---->FILE ajax.html

    und genau bis hierhin läuft das script und bricht dann - ohne kommentar - an der Stelle "downloadResponse = downloadRequest.GetResponse" ab....
    starte ich mit der "Active dir" bei bnb, so liest er aber munter weiter und die unterordner aus....

    VB.NET-Quellcode

    1. Public Function GetDataList()
    2. Return GetDataListIntern(_Server, _ActiveDir)
    3. End Function
    4. Private Function GetDataListIntern(ByVal server As String, ByVal curPath As String)
    5. Dim downloadResponseStream As Stream
    6. Dim fileStream As FileStream
    7. Dim downloadResponse As FtpWebResponse
    8. 'connect to server, and get file List
    9. Dim downloadRequest As FtpWebRequest = WebRequest.Create(server & "/" & curPath)
    10. downloadRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails
    11. downloadRequest.Credentials = New NetworkCredential(_Username, _Password)
    12. downloadRequest.Proxy = Nothing
    13. downloadResponse = downloadRequest.GetResponse
    14. downloadResponseStream = downloadResponse.GetResponseStream
    15. 'StreamReader
    16. Dim downloadReader As StreamReader
    17. downloadReader = New StreamReader(downloadResponseStream, System.Text.Encoding.UTF8)
    18. 'foreach lines...
    19. While downloadReader.EndOfStream = False
    20. Dim aLine As String = downloadReader.ReadLine()
    21. If aLine.StartsWith("d") Then
    22. 'this is a folder
    23. 'get the folder name first
    24. Dim expArray() As String = aLine.Split(" ")
    25. 'so call recursive function to download all content
    26. MsgBox(aLine & " represends a folder: " & expArray(expArray.Length - 1) & " path is: " & curPath & expArray(expArray.Length - 1) & "/")
    27. GetDataListIntern(server, curPath & expArray(expArray.Length - 1) & "/")
    28. Else
    29. 'this is a file
    30. 'get the file name first
    31. Dim expArray() As String = aLine.Split(" ")
    32. 'so call recursive function to download all content
    33. MsgBox(aLine & " represends a file: " & expArray(expArray.Length - 1))
    34. End If
    35. End While
    36. End Function