Wednesday 15 July 2015

c# - How can I list the files in a directory on ftp server? -


The problem is:

I have found a solution that can list files and directories The root of the server but I also need the contents of the directories. How do I need to modify this method?

  Internal Zero List FilesEncerver () {{ftpWebRequest ftpwrq = (FtpWebRequest) WebRequest.Create (Server); Ftpwrq.Credentials = New network credentials (user, passw); Ftpwrq.method = WebRequestMethods.Ftp.List directory; Ftpwrq.KeepAlive = false; FtpWebResponse fresponse = (FtpWebResponse) ftpwrq.GetResponse (); Streamer sr = new streamer (fresponse.GetResponsestream ()); StreamWriter SW = new streamer (new file stream ("test.txt", FileMode.Create)); Sw.WriteLine (sr.ReadToEnd ()); Sw.Close (); Fresponse.Close (); Sr.Close (); MessageBox.Show ("caught"); } Hold (exception e) {message box. Show (E. Message); }}    

You can use the following code: < Pre> FAQ = (FTPBAWEET) FTP WebRequest Create (new Yuri (SURI)); ReqFTP.UseBinary = True; ReqFTP.Credentials = New network credentials (sFtpUserID, sFtpPassword); ReqFTP.Method = WebRequestMethods.Ftp.List directory; ReqFTP.Proxy = Faucet; ReqFTP.KeepAlive = false; ReqFTP.UsePassive = false; Feedback = reqFTP.GetResponse (); Reader = new streamrider (feedback .GetresponseScream ()); String line = reader Readline (); While (line! = Null) {Results. Append (line); Result.Append ("\ n"); Line = reader. Readline (); }

No comments:

Post a Comment