I’m creating a console application in C# to which, at execution, it is passed a bunch of data. Three of them are short strings, such as username, password, etc. However, one of them is a rather lengthy XML document.
How long can the strings be, when passing them in as command-line arguments?
Are there any better alternatives out there for passing in data to a C# console app at execution?
Found here following about limitations:
The maximum command line length for the CreateProcess function is
32767 characters. This limitation comes from the UNICODE_STRING
structure.
CreateProcess is the core function for creating processes, so if you
are talking directly to Win32, then that’s the only limit you have to
worry about. But if you are reaching CreateProcess by some other
means, then the path you travel through may have other limits.
If you are using the CMD.EXE command processor, then you are also
subject to the 8192 character command line length limit imposed by
CMD.EXE.
If you are using the ShellExecute/Ex function, then you become
subject to the INTERNET_MAX_URL_LENGTH (around 2048) command line
length limit imposed by the ShellExecute/Ex functions. (If you are
running on Windows 95, then the limit is only MAX_PATH.)
What better ways or alternative – use file, maybe XML, with all your parameters there, and pass this file as command line argument.