How get web config location element?

后端 未结 5 664
忘掉有多难
忘掉有多难 2021-01-19 00:06

How get web config location element?

ConfigurationManager.GetSection(\"appSettings\") returns Okay

ConfigurationManager.GetSection(\"location\") return null         


        
5条回答
  •  旧巷少年郎
    2021-01-19 00:42

    Does this help?

    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    ConfigurationLocationCollection myLocationCollection = config.Locations;
    foreach (ConfigurationLocation myLocation in myLocationCollection)
    {
        Console.WriteLine("Location Path: {0}", myLocation.Path);
        Configuration myLocationConfiguration = myLocation.OpenConfiguration();
        Console.WriteLine("Location Configuration File Path: {0}",              myLocationConfiguration.FilePath);
    }
    Console.WriteLine("Done...");
    Console.ReadLine();
    

    Taken from here

提交回复
热议问题