Please have a look at the below code.
DirectoryInfo directory = new DirectoryInfo(@"XXXXXX \IN");
FileInfo[] files = directory.GetFiles("*.*");
foreach (var f in files) //FETCHING FILES FROM THE BULK FOLDER (IN)
{
string path_f = f.FullName;
StreamReader myfile = new StreamReader(path_f);
StreamReader basis = new StreamReader(@"C:XXXXXXXX\SCH.TXT");
while (basis.EndOfStream == false)
{
string canon = basis.ReadLine(); //CANON STORES EACH WORD FROM SCH.TXT
canon = canon.Trim();
while (myfile.EndOfStream == false)
{
string line = myfile.ReadLine();
if (line.Contains(canon))
DISCH_COUNT++;
} // END OF WHILE
} // END OF WHILE
basis.Close();
}
myfile.close();
SCH.TXT contains some words. I need to search how many times these words appeared in the a file. I am picking up each word from the SCH.txt and searching in the file.My issue is for the first word, the search is done finley. From the second word onwards the condition myfile.EndOfStream == false
is getting failed. Can you please help me regarding this..??