get application exename and path

Im using VB on Visual Studio - compact framework 2.0

How can I get the path of the exefile currently running app.exename etc. is not available in the compact framework.



Answer this question

get application exename and path

  • Gunston

    Thank you. That works.

    For VB I used this code:

    Dim appPath As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase

    appPath = System.IO.Path.GetDirectoryName(appPath)


  • Fran&#231&#59;ois296449

    How do I determine the application's root directory

    An application can determine the directory from which it was run by utilizing Reflection and easily modify it using IO.Path namespace.

    [C#]

    using System.Reflection;
    using System.IO;

    // This is the full directory and exe name
    String fullAppName = Assembly.GetExecutingAssembly().GetName().CodeBase;

    // This strips off the exe name
    String fullAppPath = Path.GetDirectoryName(fullAppName);

    From http://msdn2.microsoft.com/en-us/library/aa497276.aspx

    Cheers,

    Anthony Wong [MSFT]


  • get application exename and path