我是vb.net的新手,想要做一些非常简单的事情。我有从.ini文件读取某些文本行的代码。如何替换文本文件中的文本字符串
Dim FilePath As String = Application.StartupPath & "\bin\userconfig.ini"
Dim text As String = IO.File.ReadAllText(FilePath)
Dim newText = text.Replace("UserName = ", TextBox_NewUser.Text)
IO.File.WriteAllText(FilePath, newText)
我如何让它替换行文本的"="
与你TextBox_NewUser
输入一些东西之后。正如你可以看到的现行代码,它只是取代我不想要的整个"UserName ="
。
,在默认情况下,在.ini文本的特定行有此值:
"UserName = Unnamed"
那么,如何让刚刚替换"Unnamed"
的东西我在TextBox_NewUser
类型?
任何援助将不胜感激。
我已经使用多行来提高可读性。我希望你没关系。 –
这个“UserName = Unnamed”的情况是多个实例还是只有一个? –
如果您使用INI解析器,请参阅我的** IniManager **类(以及里面的注释示例):https://github.com/ElektroStudios/ElektroKit/tree/master/Solution/v1.2/Elektro.Application 。设置/类型 – ElektroStudios