ProcessStartInfo.Verb Propiedad

Definición

Obtiene o establece el verbo que se usará al abrir la aplicación o el documento que especifique la propiedad FileName.Gets or sets the verb to use when opening the application or document specified by the FileName property.

public:
 property System::String ^ Verb { System::String ^ get(); void set(System::String ^ value); };
public string Verb { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Verb { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Verb { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Verb { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Verb { get; set; }
member this.Verb : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Verb : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Verb : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Verb : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.VerbConverter, System.Design, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Verb : string with get, set
Public Property Verb As String

Valor de propiedad

String

Acción que se realizará con el archivo que abra el proceso.The action to take with the file that the process opens. El valor predeterminado es una cadena vacía (""), lo que significa que no se realizará ninguna acción.The default is an empty string (""), which signifies no action.

Atributos

Ejemplos

En el ejemplo de código siguiente se inicia un nuevo proceso utilizando el verbo y el nombre de archivo especificados.The following code example starts a new process by using the specified verb and file name. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado para la Verbs propiedad.This code example is part of a larger example provided for the Verbs property.

int i = 0;
var startInfo = new ProcessStartInfo(fileName);

// Display the possible verbs.
foreach (var verb in startInfo.Verbs)
{
    Console.WriteLine($"  {i++}. {verb}");
}

Console.Write("Select the index of the verb: ");
var indexInput = Console.ReadLine();
int index;
if (Int32.TryParse(indexInput, out index))
{
    if (index < 0 || index >= i)
    {
        Console.WriteLine("Invalid index value.");
        return;
    }

    var verbToUse = startInfo.Verbs[index];

    startInfo.Verb = verbToUse;
    if (verbToUse.ToLower().IndexOf("printto") >= 0)
    {
        // printto implies a specific printer.  Ask for the network address.
        // The address must be in the form \\server\printer.
        // The printer address is passed as the Arguments property.
        Console.Write("Enter the network address of the target printer: ");
        var arguments = Console.ReadLine();
        startInfo.Arguments = arguments;
    }
Dim i = 0
Dim startInfo = New ProcessStartInfo(fileName)

Dim verb As String
For Each verb In startInfo.Verbs
    ' Display the possible verbs.
    Console.WriteLine($"  {i}. {verb}")
    i += 1
Next

Console.Write("Select the index of the verb: ")
Dim indexInput = Console.ReadLine()
Dim index As Integer
If Int32.TryParse(indexInput, index) Then
    If index < 0 OrElse index >= i Then
        Console.WriteLine("Invalid index value.")
        Return
    End If

    Dim verbToUse = startInfo.Verbs(Convert.ToInt32(index))

    startInfo.Verb = verbToUse
    If verbToUse.ToLower().IndexOf("printto") >= 0 Then
        ' printto implies a specific printer.  Ask for the network address.
        ' The address must be in the form \\server\printer.
        Console.Write("Enter the network address of the target printer: ")
        Dim arguments = Console.ReadLine()
        startInfo.Arguments = arguments
    End If

Comentarios

Cada extensión de nombre de archivo tiene su propio conjunto de verbos, que se puede obtener utilizando la Verbs propiedad.Each file name extension has its own set of verbs, which can be obtained by using the Verbs property. Por ejemplo, el print verbo "" imprimirá un documento especificado mediante FileName .For example, the "print" verb will print a document specified by using FileName. El verbo predeterminado se puede especificar mediante una cadena vacía ("").The default verb can be specified by using an empty string (""). Ejemplos de verbos son "Edit", "Open", "OpenAsReadOnly", "Print" y "printto".Examples of verbs are "Edit", "Open", "OpenAsReadOnly", "Print", and "Printto". Solo se deben usar los verbos que aparecen en el conjunto de verbos devueltos por la Verbs propiedad.You should use only verbs that appear in the set of verbs returned by the Verbs property.

Al utilizar la Verb propiedad, debe incluir la extensión de nombre de archivo al establecer el valor de la FileName propiedad.When you use the Verb property, you must include the file name extension when you set the value of the FileName property. No es necesario que el nombre de archivo tenga una extensión si escribe manualmente un valor para la Verb propiedad.The file name does not need to have an extension if you manually enter a value for the Verb property.

Se aplica a

Consulte también