{
// FileStream fstream = File.Open(filePath,FileMode.Open);
using (StreamReader reader = new StreamReader(filePath))
{
string strContents = reader.ReadToEnd();
//Dictionary
int occurrences = 0;
int foundPos = -1;
int startIndex = 0;
do
{
foundPos = strContents.IndexOf(searchText, startIndex);
if (foundPos > -1)
{
startIndex = foundPos + 1;
occurrences++;
}
} while (foundPos > -1);
return occurrences;
}
}
No comments:
Post a Comment