123456789101112131415161718192021222324252627282930313233343536 |
- /* ==============================================================================
- * 功能描述:ConfigUtils
- * 创 建 者:Garrett
- * 创建日期:2019/9/16 15:26:04
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- namespace Update.Config
- {
- /// <summary>
- /// ConfigUtils
- /// </summary>
- class ConfigUtils
- {
- /// <summary>
- /// 获取配置文件
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public static string GetAppSettingsConfig(string key)
- {
- string codeBase = Assembly.GetExecutingAssembly().CodeBase;
- UriBuilder uri = new UriBuilder(codeBase);
- string path = Uri.UnescapeDataString(uri.Path);
- string addString = ConfigurationManager.OpenExeConfiguration(path).AppSettings.Settings[key].Value.ToString();
- return addString;
- }
- }
- }
|