ConfigUtils.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* ==============================================================================
  2. * 功能描述:ConfigUtils
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/9/16 15:26:04
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Configuration;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text;
  13. namespace Update.Config
  14. {
  15. /// <summary>
  16. /// ConfigUtils
  17. /// </summary>
  18. class ConfigUtils
  19. {
  20. /// <summary>
  21. /// 获取配置文件
  22. /// </summary>
  23. /// <param name="key"></param>
  24. /// <returns></returns>
  25. public static string GetAppSettingsConfig(string key)
  26. {
  27. string codeBase = Assembly.GetExecutingAssembly().CodeBase;
  28. UriBuilder uri = new UriBuilder(codeBase);
  29. string path = Uri.UnescapeDataString(uri.Path);
  30. string addString = ConfigurationManager.OpenExeConfiguration(path).AppSettings.Settings[key].Value.ToString();
  31. return addString;
  32. }
  33. }
  34. }