0

A windows .NET application may get the command line arguments which have been provided during startup. The parsing of the command line arguments and converting them to individual tokens is done by windows and the application gets an array of arguments.

Could I perform this parsing myself? The reason why I'm asking is I would like to provide the user of my application a way to specify command line options in a separate file so that the user only needs to specify this file as a command line argument.

However converting a line in a file to command line arguments is not trivial. I must support things like environment variable expansions and quoted strings.

Is there an easy way to do this?

Dalibor Čarapić
  • 2,792
  • 23
  • 38
  • No, it is built into cmd.exe. – jdweng Oct 14 '16 at 14:57
  • pass path of this file in main as argument and read this file in main – Vivek Nuna Oct 14 '16 at 15:04
  • 1
    Have you looked at the answers here? http://stackoverflow.com/questions/491595/best-way-to-parse-command-line-arguments-in-c?rq=1 – itsme86 Oct 14 '16 at 15:11
  • A silly solution, but I'll post just in case you haven't thought of it: You can maybe create a second process to wrap around your application: that process will get the file, read the line set it as the string and call your main process with that line, so the main process will then parse the arguments properly. – tzachs Oct 14 '16 at 18:44
  • I think I've found the answer in another post: http://stackoverflow.com/questions/298830/split-string-containing-command-line-parameters-into-string-in-c-sharp – Dalibor Čarapić Oct 14 '16 at 19:06

0 Answers0