Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read a C# Console app's entire command line, as it was typed? [duplicate]

I am writing a little REPL console app, and I read a command, split it, and use a piss-poor switch statement to decide which method to call (instead of using the Strategy Pattern). I then place each command into a history, for audit.

The command line when starting the app, as typed, is lost as it is already split. I would prefer to have the whole command line and get on with my loop and it's own split routine.

Is it possible to get the whole command line somehow?

like image 507
ProfK Avatar asked Apr 18 '13 06:04

ProfK


People also ask

How does read work in C?

The read() function reads data previously written to a file. If any portion of a regular file prior to the end-of-file has not been written, read() shall return bytes with value 0. For example, lseek() allows the file offset to be set beyond the end of existing data in the file.

What is the output of the C code?

When we say Output, it means to display some data on screen, printer, or in any file. C programming provides a set of built-in functions to output the data on the computer screen as well as to save it in text or binary files.


Video Answer


1 Answers

You can get the entire command line as originally passed to the program via

Environment.CommandLine

like image 59
Matthew Watson Avatar answered Sep 28 '22 16:09

Matthew Watson