123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FurnaceUI.Config
- {
- public class AppSettingsHelper
- {
- public static string GetConfigValue(string key)
- {
- try
- {
- return ConfigurationManager.AppSettings[key].ToString();
- }
- catch
- {
- return null;
- }
- }
- public static bool SetConfigValue(string key, string value)
- {
- try
- {
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
- if (config.AppSettings.Settings[key] != null)
- config.AppSettings.Settings[key].Value = value;
- else
- config.AppSettings.Settings.Add(key, value);
- config.Save(ConfigurationSaveMode.Modified);
- ConfigurationManager.RefreshSection("appSettings");
- return true;
- }
- catch
- {
- return false;
- }
- }
- }
- }
|