Application.StartupPath プロパティ

定義

実行可能ファイル名を含めず、アプリケーションを起動した実行可能ファイルのパスを取得します。

public:
 static property System::String ^ StartupPath { System::String ^ get(); };
public static string StartupPath { get; }
static member StartupPath : string
Public Shared ReadOnly Property StartupPath As String

プロパティ値

アプリケーションを起動した実行可能ファイルのパス。

このパスは、Windows フォーム アプリケーションが ClickOnce を使用して配置されるかどうかによって異なります。 ClickOnce アプリケーションは、C:\Documents and Settings\username ディレクトリのユーザーごとのアプリケーション キャッシュに格納されます。 詳細については、「 ClickOnce アプリケーションでのローカル データとリモート データへのアクセス」を参照してください。

次のコード例では、このプロパティを取得し、その値をテキスト ボックスに表示します。 この例では、 textBox1 がフォームに配置されている必要があります。

private:
   void PrintStartupPath()
   {
      textBox1->Text = String::Concat( "The path for the executable file",
        " that started the application is: ", Application::StartupPath );
   }
private void PrintStartupPath() {
    textBox1.Text = "The path for the executable file that " +
       "started the application is: " +
       Application.StartupPath;
 }
Private Sub PrintStartupPath()
   textBox1.Text = "The path for the executable file that " & _
      "started the application is: " & _
      Application.StartupPath
End Sub

適用対象