Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad ProcessStartInfo.FileName

 

Publicado: octubre de 2016

Obtiene o establece la aplicación o el documento que se va a iniciar.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

[SettingsBindableAttribute(true)]
[TypeConverterAttribute("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string FileName { get; set; }

Valor de propiedad

Type: System.String

Nombre de la aplicación que se va a iniciar o nombre de un documento que tiene un tipo de archivo asociado a una aplicación que dispone de una acción de apertura predeterminada. El valor predeterminado es una cadena vacía ("").

You must set at least the P:System.Diagnostics.ProcessStartInfo.FileName property before you start the process. The file name is any application or document. A document is defined to be any file type that has an open or default action associated with it. You can view registered file types and their associated applications for your computer by using the Folder Options dialog box, which is available through the operating system. The Advanced button leads to a dialog box that shows whether there is an open action associated with a specific registered file type.

The set of file types available to you depends in part on the value of the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property. If P:System.Diagnostics.ProcessStartInfo.UseShellExecute is true, you can start any document and perform operations on the file, such as printing, with the T:System.Diagnostics.Process component. When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is false, you can start only executables with the T:System.Diagnostics.Process component.

You can start a ClickOnce application by setting the P:System.Diagnostics.ProcessStartInfo.FileName property to the location (for example, a Web address) from which you originally installed the application. Do not start a ClickOnce application by specifying its installed location on your hard disk.

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            Process myProcess = new Process();

            try
            {
                myProcess.StartInfo.UseShellExecute = false;
                // You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
                myProcess.StartInfo.CreateNoWindow = true;
                myProcess.Start();
                // This code assumes the process you are starting will terminate itself. 
                // Given that is is started without a window so you cannot terminate it 
                // on the desktop, it must terminate itself or you can do it programmatically
                // from this application using the Kill method.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: