private static void RemoveItem() { var file = ""; var valid = true; do { valid = !valid ? true : valid; Console.Clear(); Console.Write("Please enter the file: "); file = Console.ReadLine(); } while (!File.Exists(file) && WDStorager.GetList().Any(x => x.File == file)); WDStorager.Remove(new Core.Entity.WDItemEntity(file, 0, eUnit.Megabyte)); }
static void Main(string[] args) { var exit = true; Console.Title = "WatchDog Executable"; var items = WDStorager.GetList(); if (items.IsEmptyCollection()) { Log("There is not item to watch."); Environment.Exit(0); } foreach (var item in items) { var fileInfo = new FileInfo(item.File); var size = fileInfo.Length; switch (item.Unit) { case eUnit.Megabyte: size /= 1000000; break; case eUnit.Gigabyte: size /= 1000000000; break; case eUnit.Terabyte: size /= 1000000000000; break; } if (item.Size < size) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("WARNING"); Console.WriteLine($"{item.File} with {size} {item.Unit} of {item.Size} {item.Unit} allowed."); Log($"{item.File} with {size} {item.Unit}"); exit = false; } if (!exit) { Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } Environment.Exit(0); } }