10

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.

6
  • Do you get different results in .NET vs java? Commented Jan 19, 2012 at 17:49
  • 1
    Did you try using MemoryBlobStreamClass instead of LayerFileClass? Open the lyr file with IMemoryBlobStream.LoadFromFile, then cast to IDocumentVersion. Commented 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. Commented Jan 24, 2012 at 23:05
  • It may be helpful if we understood why you're trying to detect the .lyr file version? Commented Jan 24, 2012 at 23:58
  • 1
    Because I want to know what the version is. Commented Jan 25, 2012 at 0:40

1 Answer 1

6
+50

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).

2
  • 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. Commented Jan 25, 2012 at 15:29
  • By layer types I mean FeatureLayer, RasterLayer, GroupLayer etc. Commented Jan 25, 2012 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.