ProcessStartInfo.Verbs (Propiedad)
Obtiene el conjunto de verbos asociado al tipo de archivo especificado en la propiedad FileName.
Espacio de nombres: System.Diagnostics
Ensamblado: System (en system.dll)
Ensamblado: System (en system.dll)
En el ejemplo se muestran las acciones definidas para el nombre del archivo de entrada. Si el usuario selecciona una de las acciones definidas, se inicia un nuevo proceso mediante la acción seleccionada y el nombre del archivo de entrada.
public static void PromptForProcessVerb(String fileName) { if ((fileName != null) && (fileName.Length > 0)) { // Display the verbs associated with the input // file name. ProcessStartInfo startInfo; startInfo = new ProcessStartInfo(fileName); Int32 i=1; Console.WriteLine("Supported verbs associated with {0}: ", fileName); foreach (String verb in startInfo.Verbs) { Console.WriteLine(" {0}. {1}", i.ToString(), verb); i++; } // Check if the user wants to start the process with // one of the verbs. if ((startInfo.Verbs.Length > 0) && (File.Exists(fileName))) { i = 0; Console.Write("Select a verb using its index, "); Console.WriteLine("or press Enter to exit: "); String input = Console.ReadLine(); if ((input != null) && (input.Length > 0)) { try { i = Int32.Parse(input); } catch (FormatException) { i = 0; } } // If the index is within range, start // the process using the selected verb. if ((i > 0) && (i <= startInfo.Verbs.Length)) { Console.WriteLine("Type additional process/verb arguments or press Enter to exit: "); input = Console.ReadLine(); startInfo.Verb = startInfo.Verbs[i-1]; Console.WriteLine(); if ((input != null) && (input.Length > 0)) { startInfo.Arguments = input; Console.WriteLine("Starting process: {0} {1} {2}", startInfo.Verb, startInfo.FileName, startInfo.Arguments); } else { Console.WriteLine("Starting process: {0} {1}", startInfo.Verb, startInfo.FileName); } Process newProcess = new Process(); newProcess.StartInfo = startInfo; try { newProcess.Start(); Console.WriteLine( "{0} started successfully with verb \"{1}\"!", newProcess.ProcessName, startInfo.Verb); } catch (System.ComponentModel.Win32Exception e) { Console.WriteLine(" Win32Exception caught!"); Console.WriteLine(" Win32 error = {0}", e.Message); } catch (System.InvalidOperationException) { // Catch this exception if the process exits quickly, // and the properties are not accessible. Console.WriteLine("File {0} started with verb {1}", startInfo.FileName, startInfo.Verb); } } } } else { Console.WriteLine("Invalid or empty input file name."); } }
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition
.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.
Contenido de la comunidad
Agregar