Colonel Panic Colonel Panic - 1 year ago 176
C# Question

How to access command line arguments in .csx script?

I'm using

the C# Interactive Compiler to run a
script. How can I access any command line arguments supplied to my script?

csi script.csx 2000

If you're not familiar with csi.exe, here's the usage message:

>csi /?
Microsoft (R) Visual C# Interactive Compiler version
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: csi [option] ... [script-file.csx] [script-argument] ...

Executes script-file.csx if specified, otherwise launches an interactive REPL (Read Eval Print Loop).

Answer Source

Environment.GetCommandLineArgs() returns ["csi", "script.csx", "2000"] for that example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download