2015-12-04 96 views

回答

1

檢查了這一點

using System; 
using System.Collections; 
using System.Configuration; 

class DisplayLocationInfo 
{ 
    static void Main(string[] args) 
    { 
     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(); 
    } 
} 

https://msdn.microsoft.com/en-us/library/system.configuration.configurationlocation(v=vs.100).aspx

+0

只要我打的第一OpenExeConfiguration我得到錯誤:必須指定exePath不運行時裏面有一個獨立的exe文件 應用程序是.NET 4.0 –

+0

另外,使用web.config –