guys,
I want to read a file and then find a word then print the line after that word.
without the do while loop it works and it just shows the the line after the first Match which is not my target.
when I use do while it shows the whole text file!!
any comment?
I have attached the text file as well.
here is the text file:
// #Name
// Behrooz 123_box_2000
// #JOB TITLE
// aaldkj
// adlkfj a
//
// #Requirements
// lab_121, lab_222, lab_312
//
// #Name
// John 555_box_2010
//
// #JOB TITLE
// aaldkj
// adlkfj a
//
// #Requirements
// lab_666, lab_819, lab_731
I want to read a file and then find a word then print the line after that word.
Code:
static void Main()
{
StreamReader myFile = File.OpenText(@"test.txt");
string myStringFile = myFile.ReadLine();
bool condition = false;
do
{
if (myStringFile == "// #NAME") condition = true;
{
myStringFile = myFile.ReadLine();
Console.WriteLine(myStringFile);
}
} while (myStringFile != null);
Console.ReadKey();
}
when I use do while it shows the whole text file!!
any comment?
I have attached the text file as well.
here is the text file:
// #Name
// Behrooz 123_box_2000
// #JOB TITLE
// aaldkj
// adlkfj a
//
// #Requirements
// lab_121, lab_222, lab_312
//
// #Name
// John 555_box_2010
//
// #JOB TITLE
// aaldkj
// adlkfj a
//
// #Requirements
// lab_666, lab_819, lab_731
Comment