VB.NET 如何将文本写入 .ini 文件? [英] VB.NET How to write text to a .ini file?
问题描述
我正在创建一个程序,它将帮助用户为另一个通常必须手动完成的程序创建特定的配置文件.程序配置文件读起来像;'This_Setting = 0/1(关闭/打开)'
I'm creating a program that will help users create a certain config file for another program that usually has to be done by hand. The programs config file reads it like; 'This_Setting = 0/1 (Off/On)'
所以我想这样做,如果用户勾选我的程序上的复选框,它将写入文本文件1",如果未勾选,它将写入0".
So I want to make it so that if the user ticks say a checkbox on my program, it will write in the text file '1' and if it is unticked, it will write '0'.
我想到的另一种方法是有一个文本框,用户勾选他们想要的框,然后单击一个按钮,然后它将配置代码粘贴到文本框中,以便他们可以复制/粘贴它.我个人认为这会是一个更好的选择,但我仍然没有丝毫线索.
Another way I thought about doing it was having a text box, the user ticks the boxes they want, and then click a button and then it would paste the config code in the text box so they could copy/paste it. I personally think this would be a better option, but I still have not the slightest clue how to do it.
感谢任何帮助!
推荐答案
传统的方式是使用GetPrivateProfileString
(或GetPrivateProfileSection
)来检索INI设置,而WritePrivateProfileString
(或 WritePrivateProfileSection
)来改变它们.
The traditional way is to use GetPrivateProfileString
(or GetPrivateProfileSection
) to retrieve INI settings, and WritePrivateProfileString
(or WritePrivateProfileSection
) to change them.
您可以在 PInvoke
这篇关于VB.NET 如何将文本写入 .ini 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!