保存:
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
if (config.AppSettings.Settings.AllKeys.Contains("key"))
{
config.AppSettings.Settings["key"].Value = fName;
}
else
{
config.AppSettings.Settings.Add(new KeyValueConfigurationElement("key", fName));
}
config.Save();
读取:
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
if (config.AppSettings.Settings.AllKeys.Contains("key"))
{
var fileName = config.AppSettings.Settings["key"].Value;
textBox1.Text = fileName;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章