How can I print the content of my dictionary and check when IDs are same. Like for example I get an Id like B83773, if it's appear in the dictionary I would print it on console.
Any kind of help will be super appreciated, I do not really understand the concept.
static void Main(string[] args)
{
string ExtractIDFromFileName(string filename)
{
return filename.Split('_').Last();
}
Dictionary<string, int> GetDictOfIDCounts()
{
List<string> allfiles = Directory.GetFiles("C:/filet/", "*.wish").Select(Path.GetFileNameWithoutExtension).ToList();
allfiles.AddRange(Directory.GetFiles("C:/filet/", "*.exe").Select(Path.GetFileNameWithoutExtension).ToList());
Dictionary<string, int> dict = new Dictionary<string, int>();
foreach (var x in allfiles)
{
string fileID = ExtractIDFromFileName(x);
if (dict.ContainsKey(fileID))
{
dict[fileID]++;
}
else
{
dict.Add(fileID, 1);
}
}
return dict;
}
Console.WriteLine("" );
Console.ReadLine();
}