0

我正在用 C# 开发智能设备应用程序。我想要我的应用程序的确切路径。我的应用程序驻留在我的机器上 F:/MobileAppl/ManagedAppl。

所以我想在智能设备应用程序中使用这条路径。

请确保 .net 框架的所有功能在 .net 紧凑框架中不起作用。

您能否提供我可以解决上述问题的代码或链接?

4

3 回答 3

1
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;
}
于 2010-03-04T07:43:22.317 回答
1

这应该适用于 Windows 应用程序和移动应用程序

 string path;
 path = System.IO.Path.GetDirectoryName( 
 System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );

链接文本

于 2010-03-04T07:50:15.063 回答
0
 string path = System.IO.Path.GetDirectoryName( 
 System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );

此代码不会返回正确的路径。

我的应用程序路径是 D:/Test/MobilApplication。

在执行上面的代码时,它会像这样简单地显示“//程序文件//MobilApplication”。

于 2014-01-06T11:59:53.950 回答