Пример #1
0
        private void NotifyIpChanged(string oldIp, string newIp)
        {
            log.Debug(string.Format("Notifying that the IP has changed. OLD: {0} - NEW: {1}", oldIp, newIp));

            string ftpPath = ConfigurationManager.AppSettings["ftpPath"];
            string ftpUser = ConfigurationManager.AppSettings["ftpUser"];
            string ftpPwd  = ConfigurationManager.AppSettings["ftpPwd"];

            try
            {
                FtpUtil.UploadText(ftpPath, ftpUser, ftpPwd, newIp);
            }
            catch (UriFormatException ex)
            {
                throw new ArgumentException(string.Format("Verify the ftpPath setting within appSettings section is correct; it commonly should start with \"ftp://\" - ftpPath: {0}", ftpPath), ex);
            }
            catch (WebException ex)
            {
                throw new ArgumentException(string.Format("Verify both ftpUser and ftpPwd settings within appSettings section are correct - ftpUser: {0} - ftpPwd: {0}", ftpUser, ftpPwd), ex);
            }
        }