1

I have a feature class where each feature needs a reference to a raster in another workspace.

Is there some way I can get a string that uniquely identifies any workspace (ArcSDE, personal or file)?

Since I am writing from a geoprocessing tool IDEWorkspace2.ConnectionString looked promising. However I found that it returned an empty string when the workspace was a .gdb.

Another approach I thought may work was to call IWorkSpace.ConnectionProperties and then XML serialize. However this also seems to return an empty string when the workspace is a .gdb. Not sure if I did this correctly though.

Also if there is a way to get such an unique string, how do I get a IWorkspace object from this string?

4
  • 1
    Since you'll have to code this yourself, you can use any string you want. You'll have to decide on whether to use connection filrs or save the details in your reference string itself.
    – Vince
    Commented Sep 4, 2015 at 11:00
  • I was hoping there was some built-in way to do this. Since I am writing from a geoprocessing tool IDEWorkspace2.ConnectionString looked promising. However I found that it returned an empty string when the workspace was a .gdb.
    – Andy
    Commented Sep 4, 2015 at 11:06
  • Another approach I thought may work was to call IWorkSpace.ConnectionProperties and then XML serialize.
    – Andy
    Commented Sep 4, 2015 at 11:09
  • Ask one question per post. Please edit your post. Commented Sep 4, 2015 at 11:15

1 Answer 1

0

I got the XML to work:

    public string connectionProperties2String(IPropertySet2 connectionProperties)
    {
       IXMLStream stream = new XMLStream();
       IXMLWriter writer = new XMLWriter();
       writer.WriteTo(stream as IStream);
       IXMLSerializer xsr = new XMLSerializer();
       xsr.WriteObject(writer, null, null, "", "", connectionProperties);
       return stream.SaveToString();
    }

    public IPropertySet2 string2ConnectionProperties(string scp)
    {
       IXMLStream stream = new XMLStream();
       stream.LoadFromString(scp);
       IXMLReader reader = new XMLReader();
       reader.ReadFrom(stream as IStream);
       IXMLSerializer xsr = new XMLSerializer();
       object obj = xsr.ReadObject(reader, null, null);
       return obj as IPropertySet2;
    }

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.