Advertisement
JV777

c#

Dec 13th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Foulder_Counter
  9. {
  10. class Program
  11. {
  12. class Month
  13. {
  14. public string name = "";
  15. public Dictionary<string, Day> dict_days = new Dictionary<string, Day>();
  16.  
  17. public Month(string name)
  18. {
  19. this.name = name;
  20. }
  21. }
  22.  
  23. class Day
  24. {
  25. public string name = "";
  26. public List<string> files = new List<string>();
  27.  
  28. public Day(string name)
  29. {
  30. this.name = name;
  31. }
  32. }
  33.  
  34. static void Main(string[] args)
  35. {
  36. Dictionary<string, Month> dict_month = new Dictionary<string, Month>();
  37.  
  38. string path = @"C:\Users\Egor\Desktop\m4a\test";
  39. string[] files = Directory.GetFiles(path);
  40.  
  41. foreach (string file in files)
  42. {
  43. string month = file.Substring(36,2);
  44. string day = file.Substring(39, 2);
  45.  
  46. while (true)
  47. {
  48. if (dict_month.ContainsKey(month))
  49. {
  50. if (dict_month[month].dict_days.ContainsKey(day)) { break; }
  51. else { dict_month[month].dict_days.Add(day, new Day(day)); break; }
  52. }
  53. else dict_month.Add(month, new Month(month));
  54.  
  55. }
  56.  
  57. dict_month[month].dict_days[day].files.Add(file);
  58.  
  59. }
  60.  
  61. foreach (KeyValuePair<string, Month> m in dict_month)
  62. {
  63. Console.WriteLine("Month: {0}", m.Key);
  64. foreach (KeyValuePair<string, Day> d in m.Value.dict_days)
  65. {
  66. Console.WriteLine("\tDay: {0}", d.Key);
  67. foreach (string f in d.Value.files)
  68. {
  69. Console.WriteLine(f);
  70. }
  71. }
  72. }
  73.  
  74. Console.ReadLine();
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement