Application.StartupPath 属性
获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Shared ReadOnly Property StartupPath As String
用法
Dim value As String
value = Application.StartupPath
public static string StartupPath { get; }
public:
static property String^ StartupPath {
String^ get ();
}
/** @property */
public static String get_StartupPath ()
public static function get StartupPath () : String
属性值
启动了应用程序的可执行文件的路径。
示例
下面的代码示例获取此属性并在文本框中显示其值。本示例要求 textBox1
已放置在窗体上。
Private Sub PrintStartupPath()
textBox1.Text = "The path for the executable file that " & _
"started the application is: " & _
Application.StartupPath
End Sub
private void PrintStartupPath() {
textBox1.Text = "The path for the executable file that " +
"started the application is: " +
Application.StartupPath;
}
private:
void PrintStartupPath()
{
textBox1->Text = String::Concat( "The path for the executable file",
" that started the application is: ", Application::StartupPath );
}
private void PrintStartupPath()
{
textBox1.set_Text("The path for the executable file that "
+ "started the application is: " + Application.get_StartupPath());
} //PrintStartupPath
.NET Framework 安全性
- FileIOPermission 用于获取路径。关联的枚举:FileIOPermissionAccess.PathDiscovery
平台
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 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0