|
今天写了个类库,读写指定路径的config,代码如下:
[code=csharp] public class Config
{
public static string GetConnectionString(string FileName,string ConnectionName)
{
ExeConfigurationFileMap Map = new ExeConfigurationFileMap();
Map.ExeConfigFilename = FileName;
Configuration c= ConfigurationManager.OpenMappedExeConfiguration(Map,ConfigurationUserLevel.None);
string Connectionstring = c.ConnectionStrings.ConnectionStrings[ConnectionName].ConnectionString;
return Connectionstring;
}
public static void SaveConnectionString(string FileName,string ConnectionName, string Connectionstring)
{
ExeConfigurationFileMap Map = new ExeConfigurationFileMap();
Map.ExeConfigFilename = FileName;
Configuration Config = ConfigurationManager.OpenMappedExeConfiguration(Map, ConfigurationUserLevel.None);
Config.ConnectionStrings.ConnectionStrings[ConnectionName].ConnectionString = Connectionstring;
Config.Save();
}
}[/code]
想请教下,在项目应用中,特别是那种多个应用共用一个config的情况,可是使用这个dll吗,效果实现了,但是会不会存在一些问题? |
|