我需要定期运行一个控制台应用程序,该程序需要从FTP站点下载仅 .pgp文件。FTP中的任何pgp文件都必须被下载。我已经找到了获取FTP目录清单的示例代码,并在此处编写了它:
FtpWebRequest req = (FtpWebRequest)WebRequest.Create("ftp://ourftpserver");
req.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
req.Credentials = new NetworkCredential("user", "pass");
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();
如何从目录列表中下载所有类型为.pgp的文件并将它们保存到我们服务器上的本地目录中?