예제 #1
0
        /// <summary>
        /// 下载多文件
        /// </summary>
        /// <param name="localDic">本地目录(@"D:\test")</param>
        /// <param name="remotePath">远程路径列表</param>
        /// <returns></returns>
        public int DownloadFiles(string localDic, IEnumerable <string> remoteFiles)
        {
            int count = 0;

            if (remoteFiles == null)
            {
                return(0);
            }

            try
            {
                //本地目录不存在,则自动创建
                if (!Directory.Exists(localDic))
                {
                    Directory.CreateDirectory(localDic);
                }

                if (Connect())
                {
                    count = ftpClient.DownloadFiles(localDic, remoteFiles, FtpLocalExists.Overwrite); //FtpExists.Overwrite);//  FtpLocalExists.Overwrite);
                }
            }
            catch (Exception ex)
            {
                Log4netUtil.Log4NetHelper.Error(String.Format(@"DownloadFile->下载文件 异常:{0}", ex.ToString()), @"Ftp");
            }
            finally
            {
                DisConnect();
            }

            return(count);
        }
예제 #2
0
파일: FtpRequest.cs 프로젝트: jinyuttt/ftp
 /// <summary>
 /// 下载文件到本地文件夹(已经存在的文件被忽略)
 /// </summary>
 /// <param name="localDir">本地文件夹</param>
 /// <param name="files">服务器文件</param>
 public void DownloadFiles(string localDir, string[] files)
 {
     ftp.DownloadFiles(localDir, files, FtpLocalExists.Skip, FtpVerify.None, FtpError.None, this.ReturnProgress);
 }