2

So im trying to use CommandLineArgs.Count and CommandLineArgs.ToArray If searched on the internet and they all say you use My.Application.CommandLineArgs but that does not work for me.

This is the error im getting

Error 1 The name 'My' does not exist in the current context C:\Users\Nighel\Documents\Visual Studio 2013\Projects\SOF_SCRIPT\SOF_SCRIPT\GUI.cs 119 17 SOF_SCRIPT

        if (My.Application.CommandLineArgs.Count > 0)
        {
            string[] strArray = My.Application.CommandLineArgs.ToArray<string>();
            s = strArray[0];
            if ((strArray.Length == 3) | (strArray.Length == 4))
            {
            }
        }

1 Answers1

3

Use Environment.GetCommandLineArgs():

Returns a string array containing the command-line arguments for the current process.

They are also available as parameters in the entry point of your application, static void Main(string[] args).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • So if i use Environment.GetCommandLineArgs() my exe would be able to use the information my batch file throws at it when it opens it? – Nighel Nijhuis Jul 14 '15 at 14:35