[GIS] Finding path where add-ins are installed for ArcGIS Desktop

add-inarcgis-desktoparcobjectsinstallationvb.net

I see that my add-ins are installed to
C:\Users\Me\AppData\Local\ESRI\Desktop10.0\AssemblyCache{6C90269B-D233-4122-3747-C2AE1131E22C}

Is it possible to find that file path from within the Add-in itself? e.g., someone would click a button and it would tell them the path where the add-in is located.

I want to use this location to store user-defined configuration info.

Best Answer

Here is the C# code to get the addin assembly folder:

public static string AssemblyDirectory
        {
            get
            {
                string codeBase = Assembly.GetExecutingAssembly().CodeBase;
                UriBuilder uri = new UriBuilder(codeBase);
                string path = Uri.UnescapeDataString(uri.Path);
                return Path.GetDirectoryName(path);
            }
        }

and VB.NET:

Public Shared ReadOnly Property AssemblyDirectory() As String
    Get
        Dim codeBase As String = Assembly.GetExecutingAssembly().CodeBase
        Dim uri__1 As New UriBuilder(codeBase)
        Dim path__2 As String = Uri.UnescapeDataString(uri__1.Path)
        Return Path.GetDirectoryName(path__2)
    End Get
End Property
Related Question