可以使用以下代码来读取和写入文件:

using System;
using System.IO;

class Program
{
    static void Main()
    {
        string inputFile = "a.txt";
        string outputFile = "b.txt";

        using (StreamReader reader = new StreamReader(inputFile))
        using (StreamWriter writer = new StreamWriter(outputFile))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                writer.WriteLine(line);
            }
        }

        Console.WriteLine("文件写入完成!");
    }
}

上述代码使用 StreamReader 读取输入文件的内容,并使用 StreamWriter 将每行内容写入输出文件

c# 怎么读取100M大小的atxt文本文件并以换行符分割写入到新的文件btxt

原文地址: https://www.cveoy.top/t/topic/h0K8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录