public override void Execute(Arguments arguments) { try { arguments.AssertMinimumCount(1); if (arguments.Exists(1) && arguments[1].Text == "/out") { FileName outfile = arguments[2].Text; if (outfile.Exists()) { outfile.Delete(); } fileStream = outfile.WritingStream(); writer = new StreamWriter(fileStream) { AutoFlush = true }; SetOut(writer); SetError(writer); } var file = arguments[0].FileName.Required($"File {arguments[0].Text} not found"); var chooser = new Chooser(file); chooser.Choose(); WriteLine("Done"); } finally { writer?.Close(); fileStream?.Close(); } }
protected static IResult <FileName> existingConfigurationFile() { foreach (var drive in array('C', 'E')) { FileName configurationFile = $"{drive}{PLAYGROUND_CONFIGURATION_FILE}"; if (configurationFile.Exists()) { return(configurationFile.Success()); } } return("Couldn't find configuration file".Failure <FileName>()); }
void menuConsoleSaveToFile_Click(object sender, EventArgs e) { if (dialogSaveToFile.ShowDialog() != DialogResult.OK) { return; } FileName file = dialogSaveToFile.FileName; if (file.Exists()) { file.Delete(); } file.Text = richConsole.Lines.Listify("\r\n"); }
void retrieveText() { textText.Text = textFile.Exists() ? textFile.Text : ""; }