//Downloads the files that require update. public bool DownloadFile(FilePair pair, IProgress <FtpProgress> progress) { bool result = false; using (FtpClient dlFile = new FtpClient("ftp://dcs.btac.pro/")) { dlFile.Credentials = new NetworkCredential("85th_user", "85th_user"); dlFile.Host = "ftp://dcs.btac.pro/"; dlFile.Connect(); dlFile.RetryAttempts = 3; dlFile.DownloadFile(pair.LocalFilename, pair.RemoteFileInfo.URL, FtpLocalExists.Overwrite, FtpVerify.Retry, progress); if (File.Exists(pair.LocalFilename)) { result = true; } } /*FtpWebRequest request = (FtpWebRequest)WebRequest.Create(URL + " -a"); * request.KeepAlive = true; * request.UsePassive = true; * request.UseBinary = true; * request.EnableSsl = true; * ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications; * request.Credentials = new NetworkCredential("u_name", "pw"); * request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; * FtpWebResponse response = (FtpWebResponse)request.GetResponse(); * StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII); * var remoteFile = reader.ReadLine(); * remoteFile.Substring(62);*/ /*using (var client = new WebClient()) * { * client.DownloadFile(URL, destinationFilename); * * if (File.Exists(destinationFilename)) * { * result = true; * } * }*/ return(result); }
public DownloadProgressConverter(FilePair pair) { Pair = pair; }