读取DLL自身的配置文件

读取:

ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();

configFile.ExeConfigFilename = DllConfigFilePath;

_config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);

 

保存:

Configurationconfig = CurrentDllConfiguration;
config.Save();

 

DllConfigFilePath定义:

private static stringDllConfigFilePath
{
            get
          
{
                Assemblyt_assembly = Assembly.GetCallingAssembly();
                Uri t_uri = new Uri(Path.GetDirectoryName(t_assembly.CodeBase));
               returnPath.Combine(t_uri.LocalPath, t_assembly.GetName().Name + ".dll.config");
            }
}

你可能感兴趣的:(配置文件)