ProcessStartInfo.FileName Eigenschap

Definitie

Hiermee haalt u de toepassing of het document op om te starten.

public:
 property System::String ^ FileName { System::String ^ get(); void set(System::String ^ value); };
[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.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
Public Property FileName As String

Waarde van eigenschap

De naam van de toepassing die moet worden gestart, of de naam van een document van een bestandstype dat is gekoppeld aan een toepassing en waarvoor een standaardactie voor openen beschikbaar is. De standaardwaarde is een lege tekenreeks ("").

Kenmerken

Voorbeelden

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 it 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 it 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

Opmerkingen

U moet ten minste de FileName eigenschap instellen voordat u het proces start. De bestandsnaam is een toepassing of document. Er wordt een document gedefinieerd als elk bestandstype waaraan een geopende of standaardactie is gekoppeld. U kunt geregistreerde bestandstypen en de bijbehorende toepassingen voor uw computer weergeven met behulp van het dialoogvenster Mapopties , dat beschikbaar is via het besturingssysteem. De knop Geavanceerd leidt naar een dialoogvenster waarin wordt weergegeven of er een geopende actie is gekoppeld aan een specifiek geregistreerd bestandstype.

De set bestandstypen die voor u beschikbaar zijn, is deels afhankelijk van de waarde van de UseShellExecute eigenschap. Als UseShellExecute dat het geval is true, kunt u elk document starten en bewerkingen uitvoeren op het bestand, zoals afdrukken, met het Process onderdeel. Wanneer UseShellExecute dat het is false, kunt u alleen uitvoerbare bestanden met het Process onderdeel starten.

U kunt een ClickOnce-toepassing starten door de FileName eigenschap in te stellen op de locatie (bijvoorbeeld een webadres) van waaruit u de toepassing oorspronkelijk hebt geïnstalleerd. Start een ClickOnce-toepassing niet door de geïnstalleerde locatie op uw harde schijf op te geven.

Important

Het gebruik van een exemplaar van dit type met niet-vertrouwde gegevens is een beveiligingsrisico. Gebruik dit object alleen met vertrouwde gegevens. Zie Alle invoergegevens validerenvoor meer informatie.

Van toepassing op