Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ProcessStartInfo.Verb Property

Gets or sets the verb to use when opening the application or document specified by the FileName property.

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)
[TypeConverterAttribute("System.Diagnostics.Design.VerbConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Verb { get; set; }

Property Value

Type: System.String
The action to take with the file that the process opens. The default is an empty string (""), which signifies no action.

Each file name extension has its own set of verbs, which can be obtained by using the Verbs property. For example, the "print" verb will print a document specified by using FileName. The default verb can be specified by using an empty string (""). Examples of verbs are "Edit", "Open", "OpenAsReadOnly", "Print", and "Printto". You should use only verbs that appear in the set of verbs returned by the Verbs property.

When you use the Verb property, you must include the file name extension when you set the value of the FileName property. The file name does not need to have an extension if you manually enter a value for the Verb property.

The following code example starts a new process by using the specified verb and file name. This code example is part of a larger example provided for the Verbs property.

    startInfo = new ProcessStartInfo(fileName);

    if (File.Exists(fileName))
    {
        i = 0;
        foreach (String verb in startInfo.Verbs)
        {
            // Display the possible verbs.
            Console.WriteLine("  {0}. {1}", i.ToString(), verb);
            i++;
        }
    }
}

Console.WriteLine("Select the index of the verb.");
string index = Console.ReadLine();
if (Convert.ToInt32(index) < i)
    verbToUse = startInfo.Verbs[Convert.ToInt32(index)];
else 
    return;
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.WriteLine("Enter the network address of the target printer:");
    arguments = Console.ReadLine();
    startInfo.Arguments = arguments;
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.