gpt4 book ai didi

c# - 如何在文件中替换2个双引号

转载 作者:太空宇宙 更新时间:2023-11-03 17:33:24 25 4
gpt4 key购买 nike

我有2个双引号需要替换为一个双引号。

我正在使用这种方法:

private static void ReplaceTextInFile(string originalFile, string outputFile, string searchTerm, string replaceTerm)
{
string tempLineValue;
using (FileStream inputStream = File.OpenRead(originalFile))
{
using (StreamReader inputReader = new StreamReader(inputStream))
{
using (StreamWriter outputWriter = File.AppendText(outputFile))
{
while (null != (tempLineValue = inputReader.ReadLine()))
{
outputWriter.WriteLine(tempLineValue.Replace(searchTerm, replaceTerm));
}
}
}
}
}


并这样称呼它

ReplaceTextInFile(file, file + "new", (char)34 + (char)34, (char)34);


我得到的错误是

Error   4   Argument '3': cannot convert from 'int' to 'string' 

and Error 5 Argument '4': cannot convert from 'char' to 'string'


我究竟做错了什么?

最佳答案

我会用ReplaceTextInFile(file, file + "new", "\"\"", "\"");

关于c# - 如何在文件中替换2个双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10627650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com