且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何替换文本文件中的文本字符串

更新时间:2023-02-23 09:16:11

应该很明显它替换UserName =部分,因为这正是您要求它做的。

为什么不替换未命名部分呢?类似于:

It should be obvious that it replaces the "UserName = " part because this is exactly what you are asking it to do.
Why not replacing the "Unnamed" part instead? Something like:
IO.File.WriteAllText(FilePath, IO.File.ReadAllText(FilePath).Replace("Unnamed", TextBox_NewUser.Text)


这很简单,见下文摘要

This is something really easy, see below snippet
'import System.IO
dim text as string = File.ReadAllText("test.txt")
text = text.Replace("some text", "new value")
File.WriteAllText("test.txt", text)