标签:line split ret handle new reader readline [] 存在
public void HandleTxt() { try { using (FileStream Du = new FileStream(TxtPath.Text, FileMode.Open)) { string P = TxtPath.Text; //源文件名*.log string Name = P.Substring(P.Length - 14); //原文件名 string Pa = P.Remove(P.Length - 14) + Name.Replace("log", "txt"); //新建同名txt if (File.Exists(Pa)) { MessageBox.Show("存在同名后缀为txt的文件,请删除" + Name.Replace("log", "txt")); return; } FileStream Xie = new FileStream(Pa, FileMode.Create); //新建 StreamReader sr = new StreamReader(Du, Encoding.Default); //读取 StreamWriter Wri = new StreamWriter(Xie, Encoding.Default);//写入 while (!sr.EndOfStream) { string sline = sr.ReadLine(); if (sline.IndexOf("合法刷卡") >= 0) { string[] u = sline.Split(‘(‘); Wri.WriteLine(u[2].Replace(")", "")); } } } } catch (Exception ex) { MessageBox.Show("异常!" + ex.Message); } }
标签:line split ret handle new reader readline [] 存在
原文地址:http://www.cnblogs.com/xinyibufang/p/7245868.html