Environment.CommandLine Tulajdonság

Definíció

Lekéri a folyamat parancssorát.

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

Tulajdonság értéke

Parancssori argumentumokat tartalmazó sztring.

Példák

Az alábbi példa a saját parancssorát jeleníti meg.

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

Megjegyzések

Ez a tulajdonság hozzáférést biztosít a program nevéhez és a parancssorban az aktuális folyamat indításakor megadott argumentumokhoz.

A program neve tartalmazhat elérési utat, de ehhez nem szükséges. A metódussal GetCommandLineArgs lekérheti a sztringek tömbjében elemezett és tárolt parancssori információkat.

A parancssori puffer maximális mérete nem meghatározott számú karakterre van beállítva; a számítógépen futó Windows operációs rendszertől függően változik.

A következőre érvényes:

Lásd még