Environment.CommandLine Свойство

Определение

Возвращает командную строку для этого процесса.

public:
 static property System::String ^ CommandLine { System::String ^ get(); };
public static string CommandLine { get; }
static member CommandLine : string
Public Shared ReadOnly Property CommandLine As String

Значение свойства

Строка, содержащая аргументы командной строки.

Примеры

В следующем примере отображается собственная командная строка.

using System;

class Example
{
    public static void Main()
    {
       Console.WriteLine();
       //  Invoke this sample with an arbitrary set of command line arguments.
       Console.WriteLine("CommandLine: {0}", Environment.CommandLine);
    }
}
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
open System

//  Invoke this sample with an arbitrary set of command line arguments.
printfn $"\nCommandLine: {Environment.CommandLine}"
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
Class Example
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
   End Sub 
End Class 
' The example displays output like the following:
'       C:\>CommandLine ARBITRARY TEXT
'       
'       CommandLine: CommandLine ARBITRARY TEXT

Комментарии

Это свойство предоставляет доступ к имени программы и любым аргументам, указанным в командной строке при запуске текущего процесса.

Имя программы может включать сведения о пути, но не требуется для этого. GetCommandLineArgs Используйте метод для получения данных командной строки, проанализированных и хранящихся в массиве строк.

Максимальный размер буфера командной строки не имеет определенного количества символов; Он зависит от Windows операционной системы, работающей на компьютере.

Применяется к

См. также раздел