You're print the list length in the line:
Console.WriteLine(firstone.Count);
It should be:
Console.WriteLine(firstone.Sum(f => f));
EDIT:
But as you don't really use the list at all, I would suggest you replace the foreach with this, to avoid saving a list that is not actually used.
int wordsWithTheRequiredLenghtCount = 0;
foreach (FileInfo file in Files)
{
int longWordsCount = CalculateLongWordsCount(file, 7);
wordsWithTheRequiredLenghtCount += longWordsCount;
Console.WriteLine(("W pliku: " + file.Name) + " liczba d?ugich s?ów to " + longWordsCount);
}
If you don't really need to print the file name in front of the file word count. And just want the global word count, the @Dmitry Bychenko solution is way better.
But he deleted it, so I will just replicate it here since I found it very clever.
var words = Directory
.EnumerateFiles(@"D:project_IAD", "*.sgm")
.SelectMany(file => File.ReadLines(file))
.SelectMany(line => line.Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Where(word => word.Length > minWordLength))
.Count();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…