ProcessStartInfo.FileName プロパティ

定義

起動するアプリケーションまたはドキュメントを取得または設定します。

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

プロパティ値

起動するアプリケーション名。または、アプリケーションに関連付けられていて、既定の "open" アクションが利用できるファイル タイプのドキュメント名。 既定値は、空の文字列 ("") です。

属性

#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 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 );
    }
}
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

注釈

プロセスを開始する前に、少なくとも プロパティを FileName 設定する必要があります。 ファイル名は任意のアプリケーションまたはドキュメントです。 ドキュメントは、開いているアクションまたは既定のアクションが関連付けられている任意のファイルの種類として定義されます。 オペレーティング システムで使用できる [ フォルダー オプション] ダイアログ ボックスを使用して、登録済みのファイルの種類とコンピューターに関連付けられているアプリケーションを表示できます。 [ 詳細設定 ] ボタンをクリックすると、特定の登録済みファイルの種類に関連付けられている開いているアクションがあるかどうかを示すダイアログ ボックスが表示されます。

使用できるファイルの種類のセットは、 プロパティの UseShellExecute 値によって一部異なります。 が の場合 UseShellExecutetrue、任意のドキュメントを開始し、 コンポーネントを使用してファイルに対する操作 (印刷など) を Process 実行できます。 が falseの場合UseShellExecuteは、 コンポーネントを使用Processして実行可能ファイルのみを開始できます。

ClickOnce アプリケーションを起動するには、 プロパティを FileName 、最初にアプリケーションをインストールした場所 (Web アドレスなど) に設定します。 ハード ディスクにインストールされている場所を指定して ClickOnce アプリケーションを起動しないでください。

適用対象