tags:

views:

75

answers:

2

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?

A: 
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;
}
thelost
here is a link to the above method that might be useful. http://msdn.microsoft.com/en-us/library/ms229654.aspx
SetiSeeker
After deploying the application on emulator it is giving the path as "/Program files/managedappl". But I want the path as "F:/MobileAppl/ManagedAppl". What should I need to do?
Shailesh Jaiswal
A: 

This should work well for both windows application and mobile application

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

link text

Salem309