/// <summary> /// 从指定的ftp服务器下载指定的文件到本地 /// </summary> /// <param name="name">FTP名称</param> /// <param name="name">远程文件</param> /// <param name="name">本地文件</param> protected virtual bool DownloadFile(string name, string remoteFile, string localFile) { if (GlobalMethods.Misc.IsEmptyString(name)) { return(false); } if (this.m_ftpAccessDict == null || this.m_ftpAccessDict.Count <= 0) { return(false); } if (!this.m_ftpAccessDict.ContainsKey(name)) { return(false); } bool success = false; FtpAccess ftpAccess = this.m_ftpAccessDict[name]; if (ftpAccess.OpenConnection()) { string localDirectory = GlobalMethods.IO.GetFilePath(localFile); if (GlobalMethods.IO.CreateDirectory(localDirectory)) { success = ftpAccess.Download(remoteFile, localFile); } } ftpAccess.CloseConnection(); return(false); }
/// <summary> /// 获取FTP图片 /// </summary> /// <param name="recPaperInfo"></param> /// <param name="fileName"></param> /// <returns></returns> public short GetImageFromFtp(RecPaper recPaperInfo, string fileName, ref string szLocalFile) { if (recPaperInfo == null) { return(SystemData.ReturnValue.FAILED); } FtpAccess recPaperFtpAccess = base.GetRecPaperFtpAccess(); try { if (recPaperInfo == null) { return(SystemData.ReturnValue.PARAM_ERROR); } if (!recPaperFtpAccess.OpenConnection()) { return(SystemData.ReturnValue.FAILED); } string szRemoteFilePath = GetRecPaperRemoteDir(recPaperInfo) + fileName; szLocalFile = this.GetImageLocalFile(fileName); if (!recPaperFtpAccess.ResExists(szRemoteFilePath, false)) { return(SystemData.ReturnValue.FAILED); } if (!recPaperFtpAccess.Download(szRemoteFilePath, szLocalFile)) { szLocalFile = ""; return(SystemData.ReturnValue.FAILED); } } finally { if (recPaperFtpAccess != null) { recPaperFtpAccess.CloseConnection(); } } return(SystemData.ReturnValue.OK); }