ProcessStartInfo.FileName Propiedad

Definición

Obtiene o establece la aplicación o el documento que se va a iniciar.Gets or sets the application or document to start.

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

Valor de propiedad

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.The name of the application to start, or the name of a document of a file type that is associated with an application and that has a default open action available to it. El valor predeterminado es una cadena vacía ("").The default is an empty string ("").

Atributos

Ejemplos

#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

int main()
{
    Process^ myProcess = gcnew 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 );
    }
}
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = new Process())
                {
                    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);
            }
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Public Shared Sub Main()
            Try
                Using myProcess As New Process()

                    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.
                End Using
            Catch e As Exception
                Console.WriteLine((e.Message))
            End Try
        End Sub
    End Class
End Namespace

Comentarios

Debe establecer al menos la FileName propiedad antes de iniciar el proceso.You must set at least the FileName property before you start the process. El nombre de archivo es cualquier aplicación o documento.The file name is any application or document. Un documento se define como cualquier tipo de archivo que tenga asociada una acción abierta o predeterminada.A document is defined to be any file type that has an open or default action associated with it. Puede ver los tipos de archivo registrados y sus aplicaciones asociadas para el equipo mediante el cuadro de diálogo Opciones de carpeta , que está disponible a través del sistema operativo.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. El botón Opciones avanzadas conduce a un cuadro de diálogo que muestra si hay una acción de apertura asociada a un tipo de archivo registrado específico.The Advanced button leads to a dialog box that shows whether there is an open action associated with a specific registered file type.

El conjunto de tipos de archivo disponibles depende en parte del valor de la UseShellExecute propiedad.The set of file types available to you depends in part on the value of the UseShellExecute property. Si UseShellExecute es true , puede iniciar cualquier documento y realizar operaciones en el archivo, como imprimir, con el Process componente.If UseShellExecute is true, you can start any document and perform operations on the file, such as printing, with the Process component. Cuando UseShellExecute es false , solo se pueden iniciar ejecutables con el Process componente.When UseShellExecute is false, you can start only executables with the Process component.

Puede iniciar una aplicación ClickOnce estableciendo la FileName propiedad en la ubicación (por ejemplo, una dirección web) desde la que instaló originalmente la aplicación.You can start a ClickOnce application by setting the FileName property to the location (for example, a Web address) from which you originally installed the application. No inicie una aplicación ClickOnce especificando su ubicación de instalación en el disco duro.Do not start a ClickOnce application by specifying its installed location on your hard disk.

Se aplica a