using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace convert { class Program { static void Main(string[] args) { StreamWriter swWriteFile = File.CreateText("D:\data\data\prsz.txt"); string strReadFilePath = @"D:\data\data\rsz.txt"; StreamReader srReadFile = new StreamReader(strReadFilePath); // 读取流直至文件末尾结束 while (!srReadFile.EndOfStream) { string strReadLine = srReadFile.ReadLine(); //读取每行数据 swWriteFile.WriteLine(strReadLine.Substring(strReadLine.Length - 7, 6)); //屏幕打印每行数据 } /* StreamWriter swWriteFile = File.CreateText("D:\data\data\rsz.txt"); string txt = ""; StreamReader sr = new StreamReader("D:\data\data\sz.txt", Encoding.GetEncoding("GB2312")); txt = sr.ReadToEnd(); string[] arr = txt.Split(' '); for (int i=0;i<arr.Length;i++) { swWriteFile.WriteLine(arr[i]);//写入读取的每行数据 } swWriteFile.Close(); */ } } }