Export (0) Print
Expand All

How to: Get the Application Directory 

Because there is no inherent current directory setting in Pocket PC applications, specifying a file name in your code with no path specification returns a FileNotFoundException. Pocket PC applications store data files with your assembly files under \Program Files\myAssembly\, where myAssembly is the name of your assembly.

Example

This example shows how to determine the path of the current running application by getting the fully qualified directory name of the executing assembly. Note that if the application is running in the root directory of the device, the returned path information is an empty string.

string strAppDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
MessageBox.Show(strAppDir);

Compiling the Code

This example requires references to the following namespaces:

See Also

Community Additions

ADD
Show:
© 2014 Microsoft