Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Foulder_Counter
- {
- class Program
- {
- class Month
- {
- public string name = "";
- public Dictionary<string, Day> dict_days = new Dictionary<string, Day>();
- public Month(string name)
- {
- this.name = name;
- }
- }
- class Day
- {
- public string name = "";
- public List<string> files = new List<string>();
- public Day(string name)
- {
- this.name = name;
- }
- }
- static void Main(string[] args)
- {
- Dictionary<string, Month> dict_month = new Dictionary<string, Month>();
- string path = @"C:\Users\Egor\Desktop\m4a\test";
- string[] files = Directory.GetFiles(path);
- foreach (string file in files)
- {
- string month = file.Substring(36,2);
- string day = file.Substring(39, 2);
- while (true)
- {
- if (dict_month.ContainsKey(month))
- {
- if (dict_month[month].dict_days.ContainsKey(day)) { break; }
- else { dict_month[month].dict_days.Add(day, new Day(day)); break; }
- }
- else dict_month.Add(month, new Month(month));
- }
- dict_month[month].dict_days[day].files.Add(file);
- }
- foreach (KeyValuePair<string, Month> m in dict_month)
- {
- Console.WriteLine("Month: {0}", m.Key);
- foreach (KeyValuePair<string, Day> d in m.Value.dict_days)
- {
- Console.WriteLine("\tDay: {0}", d.Key);
- foreach (string f in d.Value.files)
- {
- Console.WriteLine(f);
- }
- }
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement