How to obtain the path of the application in smart device application?
-
24-09-2019 - |
Question
I am develpoing smart device application in C#. I want the exact path of my application. My application resides on my machine at F:/MobileAppl/ManagedAppl.
So I want this path in smart device application.
Please make sure that all the functions of .net framework does not work in .net compact framework.
Can you provide me the code or link through which i can resolve the above issue?
Solution
This should work well for both windows application and mobile application
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
OTHER TIPS
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 );
this code will not return correct path .
My Application path is D:/Test/MobilApplication.
While executing above code it shows simply "//Program files//MobilApplication" like that.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow