读写文件2

class Program
{

static void Main(string[] args)
{
string path = @"D:\工资文件.txt";
string path1 = @"D:\工资文件1.txt";
using(FileStream fs=new FileStream(path,FileMode.OpenOrCreate))
{
using(StreamReader sr=new StreamReader(fs,Encoding.Default))
{
StreamWriter sw = new StreamWriter(path1);
while (true)
{
string s = sr.ReadLine();
if (string.IsNullOrEmpty(s))
{
break;
}
string[] strs = s.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
sw.WriteLine(strs[0]+"======"+int.Parse(strs[1]).ToString());
Console.WriteLine(s);

}
sw.Dispose();


}
Console.WriteLine("OK");
Console.ReadKey();
}

}



}

posted @ 2016-12-14 10:12  温柔牛  阅读(122)  评论(0编辑  收藏  举报