2011-04-20 23 views
0

我想找到Confic.INI文件從應用程序路徑,我想得值,我的意思是讀INI文件數據串......查找INI文件從應用程序的路徑和讀取INI文件Compact框架C#

我代碼 {

StreamReader的SDR =新的StreamReader(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly()。的GetName()。基本代碼)+ 「\ Confic.INI」)

//這裏我沒有獲得應用程序路徑和文件名)//

String data = file.readline(); }

請幫助我..

謝謝

回答

0

要找到應用程序目錄我用:

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) 

所以,你可以使用:

string assname=Assembly.GetExecutingAssembly().Location; // This is the assembly's name 
Path.GetDirectoryName(assname); // This is the assembly dir 
string filename=Path.Combine(dir,"Config.ini"); 
string[] ini = File.ReadAddLines(filename); 
+0

謝謝你.. 。但path.GetDirectoryname(HERE大會我沒有得到 – 2011-04-20 10:48:21

+0

@Prashanth喜悅:你是什麼意思與_H ERE大會我沒有得到_?你有沒有包含System.Reflection? – Marco 2011-04-20 10:53:30

+0

@Prashanth Joy:這是我的編輯代碼中** assname **的值? – Marco 2011-04-20 10:58:06