Hey,
Also, ich habe nochmal ein problem mit dem rekursiven löschen eines FTP Ordners.
Was will ich erreichen?
Soweit bin ich schon:
Ich weis, FTP Daten niemals in den Quellcode, wird auch später geändert, dient hier nur zum testen?
Wo liegt mein Fehler, was mach ich falsch?
:wacko:
Also, ich habe nochmal ein problem mit dem rekursiven löschen eines FTP Ordners.
Was will ich erreichen?
- Löschen eines Ordners auf meinem FTP Server, sowie alle darin enthaltene Dateien/Ordner.
Soweit bin ich schon:
VB.NET-Quellcode
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim ftpreq As FtpWebRequest = FtpWebRequest.Create("ftp://meinserver/Testfolder")
- With ftpreq
- .Credentials = New NetworkCredential("username", "password")
- .Method = WebRequestMethods.Ftp.ListDirectory
- End With
- Dim sr As New StreamReader(ftpreq.GetResponse().GetResponseStream())
- Dim str As String = sr.ReadLine()
- Dim myFtpWebRequest As FtpWebRequest
- Dim myFtpWebResponse As FtpWebResponse
- While str <> Nothing
- myFtpWebRequest = WebRequest.Create("ftp://meinserver.net/" & str)
- myFtpWebRequest.Credentials = New NetworkCredential("username", "password")
- myFtpWebRequest.Method = WebRequestMethods.Ftp.DeleteFile
- myFtpWebResponse = myFtpWebRequest.GetResponse()
- myFtpWebResponse.Close()
- str = sr.ReadLine()
- End While
- sr.Close()
- MessageBox.Show("Deleted Folder successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
- End Sub
Ich weis, FTP Daten niemals in den Quellcode, wird auch später geändert, dient hier nur zum testen?
Wo liegt mein Fehler, was mach ich falsch?
:wacko:
C# Developer
Learning C++
Learning C++