public static void DeleteLine() { Console.Clear(); Console.WriteLine("--------------------------------------------------"); Console.WriteLine("--------------------TO DO LIST--------------------"); Console.WriteLine(); Console.WriteLine("--------------------------------------------------"); Metodai.ShowList(); Console.WriteLine("--------------------------------------------------"); Console.WriteLine("--------------------------------------------------"); Console.WriteLine(); Console.WriteLine("Write a Number of Line to DELETE:"); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TODOLIST.txt"); var file = new List <string>(System.IO.File.ReadAllLines(filePath)); int l; l = Convert.ToInt32(Console.ReadLine()); if (l >= 0) { file.RemoveAt(l - 1); File.WriteAllLines(filePath, file.ToArray()); Console.WriteLine("{0}: line was deleted, press enter to go back to menu", l); } }
public static void Program() { var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TODOLIST.txt"); int option; do { ToDoMenu(); option = Metodai.ReadCommandNumber(4); var userInput = ReadCommandNumber(Enum.GetNames(typeof(MenuEnnum)).Length - 1); Console.Write("Go To: "); switch (option) { case (int)MenuEnnum.ShowList: ShowList(); break; case (int)MenuEnnum.WriteLineToFile: Console.Clear(); Console.WriteLine("--------------------------------------------------"); Console.WriteLine("-----------Write a New Line TO DO List!-----------"); WriteLineToFile(filePath, Console.ReadLine()); break; case (int)MenuEnnum.DeleteLine: DeleteLine(); break; case (int)MenuEnnum.Approve: Approve(); break; default: return; } Console.ReadKey(); Console.Clear(); }while (option != 0); Console.ReadKey(); }
public static void Main(string[] args) { Metodai.Program(); Console.ReadKey(); }