从阅读文件访问ini文件 [英] Access ini file from documents for reading
问题描述
我已经把一个配置ini文件的config.ini用于读取和从我的C#程序写的事情是,如果用户启用UAC那么对于一些奇怪的原因,程序不读取或写入文件,但它成功地创建该文件,但无法读取或写入数据。
I have put a config ini file "config.ini" for reading and writing to from my C# program, the thing is, if the user has UAC enabled then for some weird reasons the program doesn't read or write to the file but it managed to create the file but cannot read or write to it.
我怎样才能得到这个工作。
How can I get this to work.
该文件被保存到DOCUMENTSFOLDER\ProductName\config.ini
this file is saved into DOCUMENTSFOLDER\ProductName\config.ini
燕丽类文件:的 http://www.sinvise.net/so/Ini.cs
代码段config.ini文件创建的: http://www.sinvise.net/so/creation.txt一>
Code Snippet of config.ini creation: http://www.sinvise.net/so/creation.txt
推荐答案
快速建议在继续之前,你应该检查出的妮妮这是一个整洁的INI处理,并采取读护理/写INI文件。
Quick suggestion before going further, you should check out nini which is a neat INI handler and takes care of the reading/writing the INI files.
这从INI文件读取的代码示例使用。
Sample usage of the code that reads from the ini file.
using Nini;
using Nini.Config;
namespace niniDemo{
public class niniDemoClass{
public bool LoadIni(){
string configFileName = "demo.ini";
IniConfigSource configSource = new IniConfigSource(configFileName);
IConfig demoConfigSection = configSource.Configs["Demo"];
string demoVal = demoConfigSection.Get("demoVal", string.Empty);
}
}
}
试一下,并把它从那里..
Try that and take it from there...
希望这可以帮助,
最好的问候,
汤姆。
Hope this helps, Best regards, Tom.
这篇关于从阅读文件访问ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!