将一个大的文本文件分割成若干个小文本文件。
public static void Split()
{
int lineOfEach = 10000;
int fileIndex = 1;
string file = @"D:\Work\YourBigFile.csv";
var outputFile = Path.GetFileNameWithoutExtension(file) + "_" + fileIndex + ".csv";
string headerLine = "";
int lineIndex = 1;
StreamWriter sw = new StreamWriter(outputFile, false, Encoding.UTF8);
using (StreamReader sr = new StreamReader(file, Encoding.UTF8))
{
headerLine = sr.ReadLine();
while (!sr.EndOfStream)
{
var line = sr.ReadLine();
lineIndex++;
sw.WriteLine(line);
if (lineIndex % lineOfEach == 0)
{