C# WinForm中Application.StartupPath与AppDomain.CurrentDomain.BaseDirectory的区别
C# WinForm中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别示例如下:
private void Frm_Server_Load(object sender, EventArgs e)
{
MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory);
MessageBox.Show(Application.StartupPath );
}
说明:
1. AppDomain.CurrentDomain.BaseDirectory 返回结果为: D:\mycode\
Application.StartupPath 返回结果为: D:\mycode
2. Application.StartupPath 只能用于WinForm窗体中,而AppDomain.CurrentDomain.BaseDirectory既可以用于WinForm窗体中,也可以用于类库DLL文件中.
摘自:http://www.51itshare.cn/html/WangLuoBianCheng/8738/