Search code examples
compact-frameworkwindows-cecompact-framework2.0

Getting current directory in Windows CE 5.0 using C# compact 2.0


How do I get the current directory from which my EXE is running? I have tried the following two codes but they don't work.

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

Using above I get error "The name "Assembly" does not exist..."

Directory.GetCurrentDirectory()

also doesn't work.

EDIT
Ok I found another code that works but it is giving me directory "\Windows" but my program is running from an SD Card. I copied the program to "Program Files" folder on device but it again gave me directory "\Windows".

How do I get the current directory or more specifically how do I get SD Card/Flash Memory path?


Solution

  • Problem solved by using:

    System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;