ProcessStartInfo.ArgumentList Właściwość

Definicja

Pobiera kolekcję argumentów wiersza polecenia do użycia podczas uruchamiania aplikacji. Ciągi dodane do listy nie muszą być wcześniej ucieczki.

public:
 property System::Collections::ObjectModel::Collection<System::String ^> ^ ArgumentList { System::Collections::ObjectModel::Collection<System::String ^> ^ get(); };
public System.Collections.ObjectModel.Collection<string> ArgumentList { get; }
member this.ArgumentList : System.Collections.ObjectModel.Collection<string>
Public ReadOnly Property ArgumentList As Collection(Of String)

Wartość właściwości

Kolekcja argumentów wiersza polecenia.

Przykłady

W tym przykładzie dodano trzy argumenty do informacji o rozpoczęciu procesu.

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe");
info.ArgumentList.Add("/c");
info.ArgumentList.Add("dir");
info.ArgumentList.Add(@"C:\Program Files\dotnet"); // there is no need to escape the space, the API takes care of it

// or if you prefer collection property initializer syntax:

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe")
{
    ArgumentList = {
        "/c",
        "dir",
        @"C:\Program Files\dotnet"
    }
};

// The corresponding assignment to the Arguments property is:

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe")
{
    Arguments = "/c dir \"C:\\Program Files\\dotnet\""
};
Dim info As New System.Diagnostics.ProcessStartInfo("cmd.exe")
info.ArgumentList.Add("/c")
info.ArgumentList.Add("dir")
info.ArgumentList.Add("C:\Program Files\dotnet")

' The corresponding assignment to the Arguments property is:

info.Arguments = "/c dir ""C:\Program Files\dotnet"""

Uwagi

ArgumentListArguments i właściwość jest niezależna od siebie, a tylko jedna z nich może być używana w tym samym czasie. Główną różnicą między obydwoma interfejsami API jest to, że ArgumentList dba o ucieczkę podanych argumentów i wewnętrznie tworzy jeden ciąg przekazywany do systemu operacyjnego podczas wywoływania metody Process.Start(info). Jeśli więc nie masz pewności, jak prawidłowo uciec od argumentów, należy wybrać pozycję ArgumentListArguments.

Ważne

Użycie wystąpienia tego obiektu z niezaufanymi danymi jest zagrożeniem bezpieczeństwa. Użyj tego obiektu tylko z zaufanymi danymi. Aby uzyskać więcej informacji, zobacz Weryfikowanie wszystkich danych wejściowych.

Dotyczy