Environment.CommandLine Özellik

Tanım

Bu işlem için komut satırını alır.

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

Özellik Değeri

Komut satırı bağımsız değişkenlerini içeren bir dize.

Örnekler

Aşağıdaki örnekte kendi komut satırı görüntülenir.

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

Açıklamalar

Bu özellik, geçerli işlem başlatıldığında komut satırında belirtilen program adına ve bağımsız değişkenlere erişim sağlar.

Program adı yol bilgilerini içerebilir, ancak bunu yapmak için gerekli değildir. GetCommandLineArgs Ayrıştırılan ve dize dizisinde depolanan komut satırı bilgilerini almak için yöntemini kullanın.

Komut satırı arabelleğinin en büyük boyutu belirli bir karakter sayısına ayarlanmaz; bilgisayarda çalışan Windows işletim sistemine bağlı olarak değişir.

Şunlara uygulanır

Ayrıca bkz.