小编ahp*_*Per的帖子

如何替换二进制文件中的 unicode 字符串?

我一直在尝试让我的程序替换二进制文件中的 unicode。用户输入要查找的内容,程序将查找并用特定的字符串(如果可以找到的话)替换它。

我四处搜寻,但没有找到具体的信息,我想要的是这样的:

string text = File.ReadAllText(path, Encoding.Unicode);
text = text.Replace(userInput, specificString);
File.WriteAllText(path, text);
Run Code Online (Sandbox Code Playgroud)

但任何以类似方式工作的东西都应该足够了。但是,使用它会导致文件更大且无法使用。

我用:

int var = File.ReadAllText(path, Encoding.Unicode).Contains(userInput) ? 1 : 0;
if (var == 1)
{
    //Missing Part
}
Run Code Online (Sandbox Code Playgroud)

用于检查文件是否包含用户输入的字符串(如果重要)。

c# unicode

2
推荐指数
1
解决办法
2089
查看次数

标签 统计

c# ×1

unicode ×1