写入现有的ini文件 [英] Writing to an existing ini file

查看:91
本文介绍了写入现有的ini文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WritePrivateProfileString编辑现有的ini文件,并且直到在该文件中创建新节之后,它才会更新现有文件中的节.任何关于为什么编辑不起作用以及如何解决它的想法将不胜感激.

问候,

解决方案

请参阅此CodeProject文章. INI读取器/写入器类 [ ^ ]


嗨!

您可以这样阅读:

 字符串编辑器;
编辑器= File.ReadAllText(DIRECTORY->例如:c://  asd.ini); 
// 在编辑器上进行编辑
File.WriteAllText(目录,编辑器);

// 现在ini的文本已更改 


嗨!

您可以这样阅读:

//首先写入:使用System.IO;代码页的顶部.
然后:

 字符串编辑器;
编辑器= File.ReadAllText(DIRECTORY->例如:c://  asd.ini); 
// 在编辑器上进行编辑
File.WriteAllText(目录,编辑器);

// 现在ini的文本已更改 


I am attempting to edit an existing ini file using WritePrivateProfileString and it will not update the sections in an existing file until after I create a new section in that file, then it will work fine. Any ideas why the editing won''t work and how to work around it would be appreciated.

Regards,

解决方案

Have a look at this CodeProject article.INI Reader / Writer Class[^]


Hi!

you can read do this way:

string editor;
editor = File.ReadAllText(DIRECTORY-> eg: c://asd.ini);
//do your edition on editor
File.WriteAllText(DIRECTORY, editor);

//now the text of ini changed 


Hi!

you can read do this way:

//first write : using System.IO; top of the code page.
then:

string editor;
editor = File.ReadAllText(DIRECTORY-> eg: c://asd.ini);
//do your edition on editor
File.WriteAllText(DIRECTORY, editor);

//now the text of ini changed 


这篇关于写入现有的ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆