public static FtpWeb GetFtpWeb() { var checkResult = false; var pattern = false; var message = string.Empty; var ftpServerIp = UserConfigSettings.Instance.ReadSetting("题库地址"); var ftpRemotePath = UserConfigSettings.Instance.ReadSetting("题库目录"); var ftpPort = UserConfigSettings.Instance.ReadSetting("端口号"); var ftpUserId = UserConfigSettings.Instance.ReadSetting("ftp用户名"); var ftpPassword = UserConfigSettings.Instance.ReadSetting("ftp密码"); var anonymous = bool.Parse(UserConfigSettings.Instance.ReadSetting("匿名")); FtpWeb ftpWeb = null; checkResult = FtpWebTest.CheckFtp(ftpServerIp, ftpUserId, ftpPassword, ftpPort, pattern, anonymous, ftpRemotePath, out message); if (checkResult == true) { ftpWeb = new FtpWeb(ftpServerIp, ftpRemotePath, ftpUserId, ftpPassword, ftpPort, 10000, pattern, anonymous); } return(ftpWeb); }
public static bool CheckFTP(string ftpServerIp, string ftpPort, string userName, string password, bool pattern, bool anonymous) { var checkResult = false; var message = string.Empty; string ftpRemotePath = string.Empty; try { ftpRemotePath = UserConfigSettings.Instance.ReadSetting("题库目录"); checkResult = FtpWebTest.CheckFtp(ftpServerIp, userName, password, ftpPort, pattern, anonymous, ftpRemotePath, out message); if (checkResult) { message = "FTP连接成功!"; } } catch (Exception ex) { message = "测试FTP失败,原因:" + ex.Message; } return(checkResult); }