This project is read-only.

Labels.SaveToXML ?

Sep 27, 2013 at 1:42 PM

Does anyone have an example of saving Labels using Labels.SaveToXML and then restoring them using Labels.LoadFromXML?

For me, the filename argument seems to be the problem? I have tried all of the forms of a filename & path I can think of.

A code sample would be much appreciated.

Oct 2, 2013 at 10:01 AM
Will this work for you:
      if (!sf.Labels.LoadFromXML(Path.ChangeExtension(sf,Filename, ".lbl")))
        testsMethods.ReportMessage("Could not load lbl file: " + sf.Labels.get_ErrorMsg(sf.Labels.LastErrorCode));
Oct 4, 2013 at 9:23 PM
Thanks for the sample.

It does not work, oddly.

To be more specific, it works in my test app but not in the app where I need it to work!

The errors I receive are:
-No Error, or
-Invalid Filename

I am pointing the LoadFromXML to the exact same file.

I have been careful about not running the test app and the production app at the same time, so I do not believe there are any issues with conflicts between the 2 apps accessing the same file.

Anyone seen this behavior?

Oct 4, 2013 at 9:33 PM
Another error that might be a clue:

"The method applicable when labels are synchronized only", being returned by get_ErrorMsg()

Any Ideas?
Oct 4, 2013 at 9:43 PM
More details:

I am loading a series of layers from a dataset object and for each layers I am attempting to re-use the same MapWinGIS.ShapeFile object.

Is that what is causing my issue with labels?

Oct 7, 2013 at 8:39 AM
You should not re-use the same shapefile object.
Most likely you are expecting to load shapefileA.lbl but because you re-used it to load shapefileB you are trying to load shapefileB.lbl

Oct 7, 2013 at 2:02 PM
I think you nailed it.

Rather than re-using a shapefile, I am now using a new shapefile for each layer and the labels are loading correctly.