Find INI File From application path and Read INI File in Compact framework C#

▼魔方 西西 提交于 2019-12-12 04:17:59

问题


i Want To Find Confic.INI File From Application path and i want get values, i mean read INI file data to string...

My Code {

StreamReader Sdr=new StreamReader( System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)+"\Confic.INI")

//HERE I AM NOT GETTING APPLICATION PATH AND FILE NAME)//

String data=file.readline(); }

Please help me..

Thank You


回答1:


To find application dir I use:

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

So you can use:

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);


来源:https://stackoverflow.com/questions/5728755/find-ini-file-from-application-path-and-read-ini-file-in-compact-framework-c-sha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!