C#基本知识 -- App.config文件的配置与读取

对于需要配置的常量,在App.config中进行配置,格式为:

如:



     
    
    
    
  


在主程序中,需要读取App.config文件中配置的变量,采用
NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;
来获取各个变量名和变量值。如
NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;
string path = appSettings["SourceFolder"];在主程序中,需要读取App.config文件中配置的变量,采用
NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;
来获取各个变量名和变量值。如

NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;
string path = appSettings["SourceFolder"];


 

 

 

你可能感兴趣的:(开发语言)