private void Window_btnSaveClicked(object sender, EventArgs e) { // Load selected timeline Tweets tweets = (from i in TimeLines where i.Name == Window.SelectedTimeLine select i).First().GetTweets(); // Load se;ected parser Parser.Parser parser = (from i in Parsers where i.Name == Window.SelectedParser select i).First(); if (parser == null) { new ErrorDialog("There is no parser with this name"); return; } if (tweets == null) { new ErrorDialog("There was a problem loading the list"); return; } try { string path; if (Window.Path.EndsWith(parser.Extension)) { path = Window.Path; } else { // Add proper extension path = String.Concat(Window.Path, parser.Extension); } FileManager.FileWriter fileManager = new FileManager.FileWriter(path); parser.Save(tweets, fileManager.Stream); fileManager.Dispose(); SuccessDialog successDialog = new SuccessDialog("The backup was successfully performed"); Window.Hide(); } catch (Exception ex) { new ErrorDialog(ex.Message); } }