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();
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 Jan 19 '12 at 17:49
  • 1
    Did you try using MemoryBlobStreamClass instead of LayerFileClass? Open the lyr file with IMemoryBlobStream.LoadFromFile, then cast to IDocumentVersion. – Kirk Kuykendall Jan 19 '12 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. – valveLondon Jan 24 '12 at 23:05
  • It may be helpful if we understood why you're trying to detect the .lyr file version? – Stephen Quan Jan 24 '12 at 23:58
  • 1
    Because I want to know what the version is. – valveLondon Jan 25 '12 at 0:40

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. – valveLondon Jan 25 '12 at 15:29
  • By layer types I mean FeatureLayer, RasterLayer, GroupLayer etc. – Craig Williams Jan 25 '12 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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