ProcessStartInfo.FileName Propriedade

Definição

Obtém ou define o aplicativo ou documento a ser iniciado.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 da propriedade

String

O nome do aplicativo a ser iniciado ou o nome de um documento de um tipo de arquivo associado a um aplicativo e que tem uma ação abrir padrão disponível para ele.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. O padrão é uma cadeia de caracteres vazia ("").The default is an empty string ("").

Atributos

Exemplos

#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

Comentários

Você deve definir pelo menos a FileName propriedade antes de iniciar o processo.You must set at least the FileName property before you start the process. O nome do arquivo é qualquer aplicativo ou documento.The file name is any application or document. Um documento é definido para ser qualquer tipo de arquivo que tenha uma ação aberta ou padrão associada a ele.A document is defined to be any file type that has an open or default action associated with it. Você pode exibir os tipos de arquivo registrados e seus aplicativos associados para seu computador usando a caixa de diálogo Opções de pasta , que está disponível por meio do sistema operacional.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. O botão avançado leva a uma caixa de diálogo que mostra se há uma ação aberta associada a um tipo de arquivo 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.

O conjunto de tipos de arquivo disponíveis depende, em parte, do valor da UseShellExecute propriedade.The set of file types available to you depends in part on the value of the UseShellExecute property. Se UseShellExecute for true , você poderá iniciar qualquer documento e executar operações no arquivo, como impressão, com o Process componente.If UseShellExecute is true, you can start any document and perform operations on the file, such as printing, with the Process component. Quando UseShellExecute é false , você pode iniciar somente executáveis com o Process componente.When UseShellExecute is false, you can start only executables with the Process component.

Você pode iniciar um aplicativo ClickOnce definindo a FileName propriedade para o local (por exemplo, um endereço da Web) do qual você instalou originalmente o aplicativo.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. Não inicie um aplicativo ClickOnce especificando seu local instalado no disco rígido.Do not start a ClickOnce application by specifying its installed location on your hard disk.

Aplica-se a