Y_zh0811 2024-11-22 12:19 采纳率: 0%
浏览 16

关于#c##的问题:想替换红框中的文字,手动替换的话不太现实,有没有简单好上手的办法呀

想替换红框中的文字,替换成空,原始文件大约有200多万行,手动替换的话不太现实,有没有简单好上手的办法呀

img

  • 写回答

3条回答 默认 最新

  • hzlcsv 2024-11-22 13:10
    关注
    string source = "";
    string des = "";
    string[] txt = await File.ReadAllLinesAsync(source);
    StreamWriter sw = new StreamWriter(des);
    for (int i = 0; i < txt.Length; ++i)
    {
        if (txt[i].StartsWith("首页"))
        {
            i += 5;
            continue;
        }
        await sw.WriteLineAsync(txt[i]);
    }
    await sw.DisposeAsync();
    
    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 11月22日