Hi, i am very new to programming world and now i have been assign to work on for develop new application using C# code ( Microsoft visual c# 2010 express). I stuck on how to search certain keyword in the text file that read from top to bottom of the file.
Then, if the keyword that i search is found(can be one or more), i want to copy the 2line above and 2line below the keyword to other text file.
i ve tried sourcecode from Vin Jin:
private void search(String temp)
String lines = File.ReadAllLines("aa.txt");
for (int i = 0; i < lines.Length; i++)
FileStream fs = File.Create("bb.txt");
StreamWriter sw = new StreamWriter(fs);
for (int j = i - 2; j <= i + 2; j++)
It work perfect when in my text contain only one keyword that i want to search. But, my problem come when in my text file contain more then one for the keyword that i want to search. My question is, how i gonna search the keyword in my whole text files???
and then copy them in other file (bb.txt).