日期:2014-05-17  浏览次数:20768 次

FTP登陆问题
app.config内容如下

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Host" value="192.168.0.32"/>
  <add key="Path" value=""/>
  <add key="User" value="hak"/>
  <add key="Pwd" value="fff"/>
  <add key="Port" value="21"/>
  </appSettings>
</configuration>

程序代码如下

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                _ftpInfo = ReadFtpConfig();
            }
            catch (Exception rex)
            {
                MessageBox.Show("读取配置失败!错误信息:" + rex.Message);
                _isFinishUpdate = true;
                Application.Exit();
                return;
            }
        }


        private FtpInfo ReadFtpConfig()
        {
            FtpInfo ftp = new FtpInfo()
            {
                RemoteHost = ConfigurationSettings.AppSettings["Host"],
                RemotePath = ConfigurationSettings.AppSettings["Path"],
                RemoteUser = ConfigurationSettings.AppSettings["User"],
                RemotePass = ConfigurationSettings.AppSettings["Pwd"],
                RemotePort = int.Parse(ConfigurationSettings.AppSettings["Port"])