ArcCatalog Add-In: Export SDE Geodatabase (Data + Scheme)

Discussion created by Playa on Apr 30, 2012
I've just started to learn to programme and need assistance in constructing a Add-In for ArcCatalog using C#. I need to connect to an SDE Geodatabase and export the scheme and data to XML.

I found the following code to connect to an SDE Geodatabase using IWorkspaceFactory:

// For example, server = "Kona".
// Database = "SDE" or "" if Oracle.
// Instance = "5151".
// User = "vtest".
// Password = "go".
// Version = "SDE.DEFAULT".
public static IWorkspace ConnectToTransactionalVersion(String server, String
    instance, String user, String password, String database, String version)
    IPropertySet propertySet = new PropertySetClass();
    propertySet.SetProperty("SERVER", server);
    propertySet.SetProperty("INSTANCE", instance);
    propertySet.SetProperty("DATABASE", database);
    propertySet.SetProperty("USER", user);
    propertySet.SetProperty("PASSWORD", password);
    propertySet.SetProperty("VERSION", version);

    Type factoryType = Type.GetTypeFromProgID(
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
    return workspaceFactory.Open(propertySet, 0);

The following should allow you to export the current workspace (scheme and data) to xml using IGdbXmlExport.ExportWorkspace:

Public Sub ExportWorkspace ( _
    ByVal Workspace As IWorkspace, _
    ByVal outFile As String, _
    ByVal BinaryGeometry As Boolean, _
    ByVal Compressed As Boolean, _
    ByVal retrieveMetadata As Boolean _

The problem is that I'm new to C# and don't know where to begin to construct my code, any help will be appreciated.