Example #1
0
 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();
     }
 }
Example #2
0
        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>());
        }
Example #3
0
        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");
        }
Example #4
0
 void retrieveText()
 {
     textText.Text = textFile.Exists() ? textFile.Text : "";
 }