我在C#中開發智能設備應用程序。我想要我的應用程序的確切路徑。我的應用程序駐留在我的機器上F:/ MobileAppl/ManagedAppl。如何在智能設備應用程序中獲取應用程序的路徑?
所以我想在智能設備應用程序中使用此路徑。
請確保.net框架的所有功能在.net精簡框架中不起作用。
你能提供我通過哪些代碼或鏈接來解決上述問題嗎?
我在C#中開發智能設備應用程序。我想要我的應用程序的確切路徑。我的應用程序駐留在我的機器上F:/ MobileAppl/ManagedAppl。如何在智能設備應用程序中獲取應用程序的路徑?
所以我想在智能設備應用程序中使用此路徑。
請確保.net框架的所有功能在.net精簡框架中不起作用。
你能提供我通過哪些代碼或鏈接來解決上述問題嗎?
這應該適用於Windows的應用程序和移動應用
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:/ Test/MobilApplication。
在執行上面的代碼時,它會像這樣簡單地顯示「// Program files // MobilApplication」。
這裏是一個鏈接到上面的方法,可能是有用的。 http://msdn.microsoft.com/en-us/library/ms229654.aspx – SetiSeeker 2010-03-04 07:54:20
在模擬器上部署應用程序後,它將路徑設置爲「/ Program files/managedappl」。但我想要的路徑爲「F:/ MobileAppl/ManagedAppl」。我需要做什麼? – 2010-03-04 09:05:48