2012-04-12 5 views
1

Ich habe eine (Website | Windows) App und eine DLL (ClassLibrary). ich möchte den root (website | windows) config dateipfad in der dll bekommen.Get Root-Konfigurationsdateien Pfad innerhalb dll

Ich habe versucht, ConfigurationManager.OpenExeConfiguration mit verschiedenen assembly.get's, aber sie geben immer die DLL-Config-Pfad.

dank

Antwort

0

Hallo fanden diese und es funktioniert gut

Configuration config; 

     if (System.Web.HttpContext.Current != null && 
      System.Web.HttpContext.Current.Request.PhysicalPath.Equals(String.Empty) == false) 
     { 
      config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath); 
     } 
     else 
     { 
      config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
     } 

Basicly es web.config Wenn es eine Website erhalten, und es wird Wenn es eine Windows-Anwendung

bekommen app.exe.config