Hello,
I have to extract the styles from a style file into an arcobjects-object in C# but I'm a little bit stuck.
What I know so far:
* a style-file is a mdb
* all meta-informations are stored in clear-text fields inside the tables
* the actual style-informations are stored as binary-blob in the "Object-Field"
I can easily read the style-file with the "Microsoft-JET"-driver:
var conStringOledb = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path};Persist Security Info=False;";
Now comes the tricky part. I think the binary data consist of three parts:
So I transfered the guid + data parts in a memory-stream and hoped for the best:
object objectDeserialize = binaryFormatter.Deserialize(memoryStream);
But it won't work: System.Runtime.Serialization.SerializationException: "Der Eingabedatenstrom hat kein gültiges binäres Format. Die Startinhalte (in Bytes) sind: 92-C8-D0-11-8B-B6-08-00-09-EE-4E-41-02-00-0D-00-00 ..."
(The input stream is not a valid binary format. The starting contents (in bytes) are: ...)
Also I tried to manually check the guid to ensure it's the right one:
var len =bytes.Take(4).ToArray();
var guid = bytes.Skip(4).Take(16).ToArray();
var guidString = BitConverter.ToString(guid).Replace("-", string.Empty);
var sb = new StringBuilder();
sb.Append(guidString.Substring(6, 2));
sb.Append(guidString.Substring(4, 2));
sb.Append(guidString.Substring(2, 2));
sb.Append(guidString.Substring(0, 2));
sb.Append("-");
sb.Append(guidString.Substring(10, 2));
sb.Append(guidString.Substring(8, 2));
sb.Append("-");
sb.Append(guidString.Substring(14, 2));
sb.Append(guidString.Substring(12, 2));
sb.Append("-");
sb.Append(guidString.Substring(16, 4));
sb.Append("-");
sb.Append(guidString.Substring(20));
var guidObj = Guid.Parse(sb.ToString());
This one is based on the slyr-python-package. Which can import style-files into qgis.
But the created GUID is nowhere to be near the expected value.
Can anybody give me a hint/clue, what to do, what I have to watch out for?
Resources:
GitHub - nyalldawson/slyr: A Python ESRI lyr/style file converter/extracter/parser