03-08-20, 02:35 AM
PHP كود :
string dirScanner = @"\\mypath\";
if (string.IsNullOrWhiteSpace(txtSerialSearch.Text) || string.IsNullOrWhiteSpace(txtSID.Text))
return;
string[] allFiles = Directory.GetFiles(dirScanner, "*.txt");
foreach (string file in allFiles)
{
string[] lines = File.ReadAllLines(file);
string firstOccurrence = lines.FirstOrDefault(l => l.Contains(txtSerialSearch.Text));
if (firstOccurrence != null)
{
lblOutput.Text = firstOccurrence;
break;
}
}
PHP كود :
var words = new HashSet<string>(File.ReadAllLines(@"H:\\backstage\my work\uniqword.txt")); // list of words
var filewords = Directory.GetFiles(@"H:\\backstage\my work\categories file text\categories", "*.txt")
.Select(f => File.ReadAllText(f)) // read all text in each file
.SelectMany(s => words.Intersect(Regex.Split(s, @"\W|_"))) // intersect the set of words in each file with the master list of words, then flatten the list
.GroupBy(s => s).ToDictionary(w => w.Key, w => w.Count());
