Guest User

Untitled

a guest
Feb 11th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1.             string[] files = Directory.GetFiles("", "*.json", SearchOption.TopDirectoryOnly);
  2.             DateTime now = DateTime.Now;
  3.             Dictionary<string, int> names = new Dictionary<string, int>();
  4.  
  5.             foreach (string file in files)
  6.             {
  7.                 Thread thread = JsonConvert.DeserializeObject<Thread>(File.ReadAllText(file));
  8.  
  9.                 if ((now - thread.Posts.First().DateTime).TotalDays >= 7)
  10.                     continue;
  11.  
  12.                 foreach (Post post in thread.Posts)
  13.                 {
  14.                     string name = post.Name + post.Trip;
  15.  
  16.                     if (!names.ContainsKey(name))
  17.                         names.Add(name, 1);
  18.                     else
  19.                         names[name]++;
  20.                 }
  21.             }
  22.  
  23.             names = names.OrderBy(kv => kv.Value).Where(kv => kv.Value > 100).ToDictionary(kv => kv.Key, kv => kv.Value);
  24.  
  25.             foreach (var kv in names)
  26.                 Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
  27.  
  28.             Console.WriteLine("{0} total", names.Count);
Advertisement
Add Comment
Please, Sign In to add comment