ProcessStartInfo.FileName プロパティ
起動するアプリケーションまたはドキュメントを取得または設定します。
名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文
Dim instance As ProcessStartInfo Dim value As String value = instance.FileName instance.FileName = value
/** @property */ public String get_FileName () /** @property */ public void set_FileName (String value)
プロパティ値
起動するアプリケーション名。または、アプリケーションに関連付けられていて、既定の "open" アクションが利用できるファイル タイプのドキュメント名。既定値は空の文字列 ("") です。

プロセスを起動する前に、少なくとも FileName プロパティを設定する必要があります。ファイル名は、任意のアプリケーションまたはドキュメントにします。ここでいうドキュメントとは、"open" という既定のアクションが関連付けられている任意のファイル タイプです。登録されているファイル タイプと、コンピュータ上でこれらに関連付けられているアプリケーションは、オペレーティング システムを通じて利用できる [フォルダ オプション] ダイアログ ボックスで参照できます。[詳細設定] ボタンを使用すると、登録されている特定のファイル タイプに "open" アクションが関連付けられているかどうかを示すダイアログ ボックスが表示されます。
利用できるファイルの種類のセットは、UseShellExecute プロパティの値によって一部異なります。UseShellExecute が true の場合は、Process コンポーネントを使用して、任意のドキュメントを起動し、印刷などのファイルに対する操作を実行できます。UseShellExecute が false の場合は、Process コンポーネントを使用して、実行可能ファイルの起動だけ実行できます。

Imports System Imports System.Diagnostics Imports System.ComponentModel Namespace MyProcessSample _ '/ <summary> '/ Shell for the sample. '/ </summary> Class MyProcess ' These are the Win32 error code for file not found or access denied. Private ERROR_FILE_NOT_FOUND As Integer = 2 Private ERROR_ACCESS_DENIED As Integer = 5 '/ <summary> '/ Prints a file with a .doc extension. '/ </summary> Sub PrintDoc() Dim myProcess As New Process() Try ' Get the path that stores user documents. Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc" myProcess.StartInfo.Verb = "Print" myProcess.StartInfo.CreateNoWindow = True myProcess.Start() Catch e As Win32Exception If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then Console.WriteLine((e.Message + ". Check the path.")) Else If e.NativeErrorCode = ERROR_ACCESS_DENIED Then ' Note that if your word processor might generate exceptions ' such as this, which are handled first. Console.WriteLine((e.Message + ". You do not have permission to print this file.")) End If End If End Try End Sub 'PrintDoc Public Shared Sub Main() Dim myProcess As New MyProcess() myProcess.PrintDoc() End Sub 'Main End Class 'MyProcess End Namespace 'MyProcessSample
using System; using System.Diagnostics; using System.ComponentModel; namespace MyProcessSample { /// <summary> /// Shell for the sample. /// </summary> class MyProcess { // These are the Win32 error code for file not found or access denied. const int ERROR_FILE_NOT_FOUND =2; const int ERROR_ACCESS_DENIED = 5; /// <summary> /// Prints a file with a .doc extension. /// </summary> void PrintDoc() { Process myProcess = new Process(); try { // Get the path that stores user documents. string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc"; myProcess.StartInfo.Verb = "Print"; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); } catch (Win32Exception e) { if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND) { Console.WriteLine(e.Message + ". Check the path."); } else if (e.NativeErrorCode == ERROR_ACCESS_DENIED) { // Note that if your word processor might generate exceptions // such as this, which are handled first. Console.WriteLine(e.Message + ". You do not have permission to print this file."); } } } public static void Main() { MyProcess myProcess = new MyProcess(); myProcess.PrintDoc(); } } }
#using <System.dll> using namespace System; using namespace System::Diagnostics; using namespace System::ComponentModel; // These are the Win32 error code for file not found or access denied. #define ERROR_FILE_NOT_FOUND 2 #define ERROR_ACCESS_DENIED 5 int main() { Process^ myProcess = gcnew Process; try { // Get the path that stores user documents. String^ myDocumentsPath = Environment::GetFolderPath( Environment::SpecialFolder::Personal ); myProcess->StartInfo->FileName = String::Concat( myDocumentsPath, "\\MyFile.doc" ); myProcess->StartInfo->Verb = "Print"; myProcess->StartInfo->CreateNoWindow = true; myProcess->Start(); } catch ( Win32Exception^ e ) { if ( e->NativeErrorCode == ERROR_FILE_NOT_FOUND ) { Console::WriteLine( "{0}. Check the path.", e->Message ); } else if ( e->NativeErrorCode == ERROR_ACCESS_DENIED ) { // Note that if your word processor might generate exceptions // such as this, which are handled first. Console::WriteLine( "{0}. You do not have permission to print this file.", e->Message ); } } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からProcessStartInfo.FileName プロパティを検索する場合は、下記のリンクをクリックしてください。

- ProcessStartInfo.FileName プロパティのページへのリンク