I've been through IStorage, Microsoft Compound File Spec, ArcObjects deserialization etc. trying to detect the .lyr file version.
Using ArcObjects, I can get at the Layer properties, data source, extent, etc, but the documentVersion property of the LayerFileClass always reports back 'esriArcGISVersion10' on 9.3 Layer files.
ILayerFile l = new LayerFileClass();
l.Open(fileName);
LayerFileClass t = (LayerFileClass)l;
string version = t.DocumentVersion.ToString();
Any help is appreciated.
Note this crusty forum post from 2007.
-
Do you get different results in .NET vs java?Kirk Kuykendall– Kirk Kuykendall2012年01月19日 17:49:36 +00:00Commented Jan 19, 2012 at 17:49
-
1Did you try using MemoryBlobStreamClass instead of LayerFileClass? Open the lyr file with IMemoryBlobStream.LoadFromFile, then cast to IDocumentVersion.Kirk Kuykendall– Kirk Kuykendall2012年01月19日 17:59:02 +00:00Commented Jan 19, 2012 at 17:59
-
RE comment 2: I just tried -- I get esriArcGISVersion10 for 8.3, 9/9.1, 9.2 and 9.3 layer files. RE comment 1: Java....? What's that? ;) Thanks for your help. I don't think it's possible.Random Geo guy– Random Geo guy2012年01月24日 23:05:06 +00:00Commented Jan 24, 2012 at 23:05
-
It may be helpful if we understood why you're trying to detect the .lyr file version?Stephen Quan– Stephen Quan2012年01月24日 23:58:00 +00:00Commented Jan 24, 2012 at 23:58
-
1Because I want to know what the version is.Random Geo guy– Random Geo guy2012年01月25日 00:40:24 +00:00Commented Jan 25, 2012 at 0:40
1 Answer 1
Once a layer file is loaded, it is the current version as opening upgrades it. The DocumentVersion property exists solely to set a version for save back to a prior version with the LayerFile class.
The actual document version is not written to a layer file. The only version information written is the internal persistence version of the object. This information can be extracted via structured storage but you'd need a lookup of this version number for every possible layer type (and you'd also need to extract the layer type guid to even tell the layer type).
-
Thanks for the answer but I'm a little lost by it. What is meant by 'every possible layer type' -- as far as I can tell there are five possible versions: 8.3, 9/9.1, 9.2, 9.3 and 10.Random Geo guy– Random Geo guy2012年01月25日 15:29:40 +00:00Commented Jan 25, 2012 at 15:29
-
By layer types I mean FeatureLayer, RasterLayer, GroupLayer etc.Craig Williams– Craig Williams2012年01月25日 21:34:14 +00:00Commented Jan 25, 2012 at 21:34