两个文件匹配建立新文件
一次偶然朋友问了一下,思考了一下,做出来的东东
private void f()
{
//telephone
StreamReader srReadLine2 = new StreamReader((System.IO.Stream)File.OpenRead("c:\\User.txt"), System.Text.Encoding.Default);
//tele
string text2=srReadLine2.ReadLine();
while(text2!=null)
{
StreamReader srReadLine1 = new StreamReader((System.IO.Stream)File.OpenRead("c:\\swzhineng(2).txt"),System.Text.Encoding.Default);
string text1=srReadLine1.ReadLine();
while(text1!=null)
{
if(text1.IndexOf(text2)==-1)
{
text1=srReadLine1.ReadLine();
continue;
}
else
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\4.txt",true);
sw.Write(text1);
sw.Close();
break;
}
}
text2=srReadLine2.ReadLine();
srReadLine1.Close();
}
srReadLine2.Close();
}