I want to search list of words in multiple text files and compute number of files that contain word.
my code take alot of time reach to hours.
uniqword = File.ReadAllLines(@"H:\\backstage\my work\uniqword.txt").ToList();
string[] allfile = Directory.GetFiles(@"H:\\backstage\my work\categories file text\categories", "*.txt");
var no_doc_word = new Dictionary<string, int>();
foreach (string ff1 in allfile)// read one file in files until finish
{
List<string> allLinesText = File.ReadAllLines(ff1).ToList();
foreach (string word in uniqword)
{
if (allLinesText.Contains(word))
if (no_doc_word.ContainsKey(word))
no_doc_word[word]++;
else
no_doc_word.Add(word, 1);
}
}