net 读取ini文件

ServiceConfig.ini
文件内容:

[General]

StationLine=DL1
StationGroup=EMKAU
StationId=EMKAU11
Section=Emilie_Connection
Printer=FinePrint
CultureInfo=zh-TW

[Emilie_Connection]
srvAddress = tcp://172.1.5.2:2103/RoutingObject.Routing

主文件读取.ini文件内容[ DllImport ( "kernel32" ) ]
  private static extern int GetPrivateProfileString ( string    section ,string key , string def , StringBuilder retVal ,int size , string filePath ) ;
  StringBuilder temp = new StringBuilder ( 255 ) ;
  GetPrivateProfileString("General", "Section", "", temp, 255, configFilePath);
  section = temp.ToString();
  GetPrivateProfileString("General", "StationLine", "", temp, 255, configFilePath);
  lineID = temp.ToString();
  temp.Remove(0, temp.Length);
  GetPrivateProfileString("General", "StationGroup", "", temp, 255, configFilePath);
  STATION_GROUP_NAME = temp.ToString();
  temp.Remove(0, temp.Length);
  GetPrivateProfileString("General", "StationId", "", temp, 255, configFilePath);
  STATION_ID = temp.ToString();

你可能感兴趣的:(.net)