Solved! Go to Solution.
IStyleGallery StyleGallery = new StyleGalleryClass(); IStyleGalleryStorage StyleGalleryStorage = StyleGallery as IStyleGalleryStorage; // This is Program Files styles folder string default = StyleGalleryStorage.DefaultLocation; // All loaded style files for (int i = 0; i < StyleGalleryStorage.FileCount; i++) { string fullFilePath = StyleGalleryStorage.get_File(i); // Now you can get directory string dir = System.IO.Path.GetDirectoryName(fullFilePath); if (!string.IsNullOrEmpty(dir) && System.IO.Directory.Exists(dir)) { // Do smth } }
You can get the styles from the registry. In 10.0 it is under HKEY_LOCAL_MACHINE\Software\ESRI\Desktop10.0\CoreRuntime\StyleDir. I assume desktop 10.1 has something very similar.
The main annoyance of using that method is you would have to update the code every time you changed version...
You might be better off getting a reference to the ArcMap.exe through .net reflections which gives you the path to the bin directory and work your way back to styles. Of course if esri changes the location in a future version, that won't work either.
IStyleGallery StyleGallery = new StyleGalleryClass(); IStyleGalleryStorage StyleGalleryStorage = StyleGallery as IStyleGalleryStorage; // This is Program Files styles folder string default = StyleGalleryStorage.DefaultLocation; // All loaded style files for (int i = 0; i < StyleGalleryStorage.FileCount; i++) { string fullFilePath = StyleGalleryStorage.get_File(i); // Now you can get directory string dir = System.IO.Path.GetDirectoryName(fullFilePath); if (!string.IsNullOrEmpty(dir) && System.IO.Directory.Exists(dir)) { // Do smth } }