public ListOption(string username) // constructor { listDirectory = "./account_list/" + username + "/lists"; activeUser = username; file_handler = new MyFileHandler(username); lists = file_handler.GetAvailableList(listDirectory); }
public string[] ShowList(string username) // for current user show list, or get list { var file = new MyFileHandler(username); string listDirectory = $@"./account_list/{username}/lists"; string[] lists = file.GetAvailableList(listDirectory); if (lists.Length != 0) //check if any list exists { while (true) { int listNumber = ValidateChoice.GetNumber(lists.Length, "Lists created by " + username, lists); if (listNumber == 0) //exit { break; } try { string[] toDoList = File.ReadAllLines($@"{listDirectory}/{lists[listNumber-1]}.txt"); if (toDoList.Length == 0) { MenuPrinter.PrintMenu(lists[listNumber - 1] + " List", null, new string[] { "List is empty..." }); break; } else { MenuPrinter.PrintMenu(lists[listNumber - 1] + " List", toDoList, null); return(toDoList); } } catch { Console.WriteLine("> The list you gave us does not exist!"); Console.ReadKey(); Console.Clear(); continue; } } } else { Console.WriteLine("> No List Exists..."); } return(null); }