需求是分割一段文字,按要求分割成多个文本。
现在的问题是,分割后,只创建了一份文件,怎样才能创建多个文件呢?
比如Source.txt内容为:
111
222
111
333
111
444
要求分割成3个文件
文件1.txt
111
222文件2.txt
111
333文件3.txt
111
444但是我现在遇到的问题是:
只生成了1个文件,而且内容也不对
文件1.txt
111
444strTempFileBuilder = new StringBuilder();
do
{
 string path = Path.Combine(FilePath, strfileName);                 
                    FileInfo finfo = new FileInfo(path);
                    FileStream fs = finfo.OpenWrite();
                    StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
                    sw.WriteLine(strTempFileBuilder);
                    sw.Flush();             
                    fs.Flush();
                    sw.Close();
                    fs.Close();
                  
                    displayCount = 0;
                    isSplited = true;
                    strTempFileBuilder = new StringBuilder();}while(reader.ReadLine() != null)