I'm developing an ArcGIS Pro plugin. I would like to set the properties of a layer based on a layer files (.lyrx) that I would like to provide as part of the plugin deployment.
Therefore I used the LayerDocument class, constructed from a layer file path:
var lyrDocFromLyrxFile = new LayerDocument(@"c:\data\layer.lyrx");
However, this seem to require an absolute path, and therefore this layer file must be installed there by the user.
I can add the layerfile to the solution such that it is distributed with the plugin package. How do I construct a proper path to the resource in the package. Since the package is just a zip-file, and the resource is put with the dlls in the Install folder, I would expect the following to work:
var dllPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
var layerFile = System.IO.Path.Combine(dllPath, @"Install\LayersFiles\KILOMETERRIBBON.lyrx");
var lyrDocFromLyrxFile = new LayerDocument(layerFile);
However this provides an empty layer definition.