论坛首页 入门技术论坛

net 读取ini文件

浏览 2049 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-04-15  
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();
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics