Application.StartupPath 屬性

定義

取得啟動應用程式的可執行檔路徑,不包括檔名。

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

屬性值

String

啟動應用程式的可執行檔路徑。

此路徑會根據Windows Forms應用程式是否使用 ClickOnce 來部署而有所不同。 ClickOnce應用程式會儲存在 C:\Documents 和 設定 \ 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

適用於