Environment.CommandLine Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan baris perintah untuk proses ini.
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
Nilai Properti
String yang berisi argumen baris perintah.
Contoh
Contoh berikut menampilkan baris perintahnya sendiri.
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
Keterangan
Properti ini menyediakan akses ke nama program dan argumen apa pun yang ditentukan pada baris perintah ketika proses saat ini dimulai.
Nama program dapat mencakup informasi jalur, tetapi tidak diperlukan untuk melakukannya. GetCommandLineArgs Gunakan metode untuk mengambil informasi baris perintah yang diurai dan disimpan dalam array string.
Ukuran maksimum buffer baris perintah tidak diatur ke jumlah karakter tertentu; bervariasi tergantung pada sistem operasi Windows yang berjalan di komputer.