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.
-
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 Functionuser4979– user49792011年11月30日 19:04:28 +00:00Commented Nov 30, 2011 at 19:04
-
3You 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.blah238– blah2382011年11月30日 20:30:42 +00:00Commented 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/…JC5577– JC55772011年11月30日 21:51:34 +00:00Commented 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?PolyGeo– PolyGeo ♦2015年02月15日 01:46:03 +00:00Commented Feb 15, 2015 at 1:46
-
@PolyGeo It was not an answer, just a suggestion.blah238– blah2382015年02月15日 15:01:45 +00:00Commented Feb 15, 2015 at 15:01
2 Answers 2
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
If you are using Python, you can find the folder location by doing the following
import os
print os.path.dirname(__file__)
-
Python add-ins did not appear until ArcGIS 10.1 for Desktop and this is a 10.0 question so the type of add-ins involved are described at help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/…2015年02月15日 01:43:25 +00:00Commented Feb 15, 2015 at 1:43
Explore related questions
See similar questions with these tags.