public void saveOptions(Options options) { XmlSerializer formatter = new XmlSerializer(typeof(Options)); try { stream = File.Open(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "options.xml", FileMode.OpenOrCreate); formatter.Serialize(stream, options); stream.Dispose(); } catch { stream.Dispose(); } }
public static void Main(string[] args) { System.Console.WriteLine("Current Version: " + version); options = new Options(true); options.autoSort = false; DateTime timeStart = DateTime.Now; FileSystemWatcher fileWatcher = new FileSystemWatcher(options.autoSource); fileWatcher.Changed += new FileSystemEventHandler(fileEventHandler); fileWatcher.Created += new FileSystemEventHandler(fileEventHandler); fileWatcher.Deleted += new FileSystemEventHandler(fileEventHandler); fileWatcher.EnableRaisingEvents = true; while (options.operational) { switch (MainMenu()) { case ("Manually Sort"): Sorter.sort(); break; case ("Exit Application"): options.operational = false; break; case ("Change Options"): ChangeOptions(); fileWatcher.Path = options.autoSource; break; default: options.operational = false; break; } } DateTime timeEnd = DateTime.Now; System.Console.WriteLine("Operation lasted " + MillisDifference(timeStart, timeEnd)); System.Console.Write("Exiting..."); options.saveOptions(options); System.Console.Read(); }