Visual Studio 2015 Update 1 includes the CSI.EXE tool , which allows you to run .CSX scripts, written directly in C#. I would like to know how I can read the arguments passed to CSI.EXE on the command line and directed to the code being executed, not the tool itself. I know there must be a way, because when I run csi /?
the following appears as part of the help:
-- Indicates that the remaining arguments should not be treated as options.
namely,
-- Indicates that all other arguments should not be treated as options.
so when executing csi MiPrograma.csx /foo /bar -- fizz buzz
, there must be some way for the code to access fizz buzz
.
I've even looked at the source code for CSI.EXE and its associated classes, but can't find any clues. Any ideas?
To read the parameters you can use the GetCommandLineArgs function .
For example the code
produces the output
To complement josejuan's answer, the following statement gives me the arguments passed to the code, without the
--
previous arguments: