ILayerFile.Save() fails with COM Exception

435
2
05-05-2010 04:59 PM
NevinFry
New Contributor
Hi,
I'm trying to save all the layers from a Globe Document out to layer files.
I have code like this:

IEnumLayer baseLayers = globe.get_GlobeLayers(null, true, true, true);
for (ILayer lyr = baseLayers.Next(); lyr != null; lyr = baseLayers.Next())
{
     ....

     ILayerFile lf = new LayerFileClass();
     lf.New(somePathName);
     lf.ReplaceContents(lyr);
     lf.Save();
     lf.Close();
}

However, lf.Save() always fails with a COM Exception on every layer.
This is at 9.3.1.
What am I doing wrong?

Thanks.
0 Kudos
2 Replies
KirkKuykendall
Occasional Contributor III
does somePathName refer to a file that exists?

If not, maybe try ILayer.SaveAs(somePathName) instead.
0 Kudos
NevinFry
New Contributor
I've tried various iterations with SaveAs() and it still produces the same COM Exception.
0 Kudos