7

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 30, 2011 at 18:47
5
  • won't let me post my own answer yet, so here it is: This returns full path to the .dll Public Function FindMe() As String FindMe = System.Reflection.Assembly.GetExecutingAssembly().Location ' MsgBox(FindMe) return FindMe End Function Commented Nov 30, 2011 at 19:04
  • 3
    You might consider creating a well-known folder under %APPDATA% to store user configuration data rather than in the AssemblyCache folder as this is subject to deletion by the add-in framework and as you have seen requires reflection to determine. Commented Nov 30, 2011 at 20:30
  • 1
    @user4979: you might want to check out this question if you are looking at adding user scoped settings: gis.stackexchange.com/questions/9001/… Commented Nov 30, 2011 at 21:51
  • @blah238 user4979 has not been seen here for over 3 years, and I do not have the knowledge to translate their (and/or your) comment into an answer. Could you perhaps do so sometime? Commented Feb 15, 2015 at 1:46
  • @PolyGeo It was not an answer, just a suggestion. Commented Feb 15, 2015 at 15:01

2 Answers 2

3

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
answered Feb 15, 2015 at 8:03
0

If you are using Python, you can find the folder location by doing the following

import os
print os.path.dirname(__file__)
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Oct 16, 2012 at 16:40
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.