I'm using System.Process to launch an external program, and I've just got a "filename or extension is too long" exception. However, I believe that filename is fine, but arguments is one hell of a long string (33,000 symbols). Can that string cause the exception?
Yes. That text is the error message corresponding to ERROR_FILENAME_EXCED_RANGE, and other users report that it applies to the overall command length and not just the executable filename. See also
You are certainly exceeding the limit, although I agree the error message could be better. The CreateProcess documentation says:
lpCommandLine [in, out, optional]The command line to be executed. The maximum length of this string is 32,768 characters, including the Unicode terminating null character. If
lpApplicationNameis NULL, the module name portion oflpCommandLineis limited toMAX_PATHcharacters.
For ShellExecute the limit is even lower. Hans linked a great blog series by Raymond Chen that discussed these limits and workarounds, see the question comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With