在我的程序中,我需要从默认位置复制一个模板数据库,据我所知,这将根据我选择使用的安装程序而有所不同。问题是我似乎无法读取 |DataDirectory| 的实际路径我知道我应该使用 AppDomain.CurrentDomain.GetData("DataDirectory") 但它总是在调试器中返回 Null,这意味着我无法测试我的代码。我尝试了以下两种语法:
string sourcePath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
和
string defaultpath = Convert.ToString(AppDomain.CurrentDomain.GetData("DataDirectory"));
我做错了什么吗?
感谢!
最佳答案
试试APPBASE
AppDomain.CurrentDomain.GetData("APPBASE")
http://msdn.microsoft.com/en-us/library/system.appdomainsetup.applicationbase.aspx
如果你想要DataDirectory
键你必须在SetData
之前执行
关于c# - AppDomain.CurrentDomain.GetData ("DataDirectory") 总是返回 Null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12286720/