Hi all
I've been trying without sucess to write values back to my app.coonfig. I have put my config and code below as I am having zero luck but I have followed MSDN/google pages.
Does anyone know where I am going wrong?
thanks
config.AppSettings.Settings["FTPHost"].Value = tbFtpHost.Text;
config.AppSettings.Settings["FTPUserName"].Value = tbFtpUsername.Text;
config.AppSettings.Settings["FTPUserPasswd"].Value = tbFtpUserpasswd.Text;
config.AppSettings.Settings["FTPRemoteDir"].Value = tbFtpRemoteDir.Text;
config.AppSettings.Settings.Remove("FTPHost");
config.AppSettings.Settings.Add("FTPHost", tbFtpHost.Text);
config.AppSettings.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="FTPHost" value="host.domain.com"/>
<add key="FTPUserName" value="username"/>
<add key="FTPUserPasswd" value="password"/>
<add key="FTPRemoteDir" value="/u1/EDI_DROP"/>
</appSettings>
</configuration>