public List <SingleTask> GetTasks() { string Path = GetPathAndThrowExeptionIfRequired(); List <SingleTask> AllTask = new List <SingleTask>(); string CurrTask; using (StreamReader SR = new StreamReader(Path)) { CurrTask = SR.ReadLine(); CurrTask = SR.ReadLine(); while ((CurrTask = SR.ReadLine()) != null) { char[] seperator = { ' ' }; string[] tokenize = CurrTask.Split(seperator, 2, StringSplitOptions.RemoveEmptyEntries); if (tokenize.Length == 2) { try { AllTask.Add(new SingleTask( TimeSpan.Parse(tokenize[0]), tokenize[1], TimeSpan.Parse(tokenize[1].Substring(tokenize[1].Length - 8)) )); } catch (Exception) { } } } } return(AllTask); }
public static List <SingleTask> GetTodayTaskFile(DateTime date) { string path = GetTaskFilePath(date); List <SingleTask> AllTask = new List <SingleTask>(); string CurrTask; using (StreamReader sw = new StreamReader(path)) { CurrTask = sw.ReadLine(); CurrTask = sw.ReadLine(); while ((CurrTask = sw.ReadLine()) != null) { char[] seperator = { ' ' }; string[] tokenize = CurrTask.Split(seperator, 2, StringSplitOptions.RemoveEmptyEntries); AllTask.Add(new SingleTask(TimeSpan.Parse(tokenize[0]), tokenize[1])); } } return(AllTask); }