题
我develpoing在C#智能设备应用程序。我想我的应用程序的确切路径。我的应用程序驻留在我的机器以F:/ MobileAppl / ManagedAppl
所以,我想在智能设备应用程序这条路。
请确保所有.NET Framework的功能,不以.NET精简框架的工作。
你能为我提供的代码或链接,通过它我可以解决上述问题?
解决方案
这应当为两个窗口应用和移动应用
很好地工作 string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
其他提示
public static string getPath()
{
string fullname;
string myAppPath;
fullname = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
myAppPath = System.IO.Path.GetDirectoryName(fullname);
myAppPath = myAppPath.Replace("file:\\", "");
return myAppPath;
}
string path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
这个代码将不会返回正确的路径。
我的应用路径是d:/测试/ MobilApplication
尽管上面的代码执行它简单地示出了“//程序文件// MobilApplication”这样。
不隶属于 StackOverflow