How to synchronize a replica in a disconnected environment


This sample demonstrates how to synchronize a replica in a disconnected environment. A disconnected environment means that the geodatabases involved are not connected by a computer network.
In a disconnected environment the synchronization process is completed in two separate steps:
Step 1 - Exporting a replica message from one geodataserver. This can be a data changes message or an acknowledgement message
Step 2 - Importing the message into the relative geodataserver.
 
This sample includes numerous routines that demonstrate how to synchronize replica messages (XML) between geodataservers under different circumstances. Half of the routines demonstrate connecting to GeoDataServers via a local connection to ArcSDE servers, and the other half connect over a WAN using ArcGIS server. Depending on your environment, you can choose the routines that apply to you and modify them to suit your needs. The routines demonstrate how to export data change messages, export acknowledgement messages, import data change messages and import acknowledgement messages.
 
The routines that export data change messages generate a delta xml file which is written in compressed format (.ZIP). This .zip file will be written to an output directory specified in the routine. This location has been hard-coded and should be modified to point to a directory on your local drive. If this location does not exist it will be created. If it does exist this folder will be replaced.
 
Similarly, the routines that import data change messages also work with compressed XML files. The routine expects that the .ZIP file to be imported is located in the input directory specified in the routine. This location has been hard-coded and should be modified to point to a directory on your local drive. It is assumed that there is only one file in this directory.
The routines that export acknowledgement files work similarly to those that export data change messages in that they require specifying a local directory to write the file to. However, the generated acknowledgment files are not compressed, they are simple XML documents. Similarly, the routines that import acknowledgement messages expect the XML file to be imported is located in the input directory specified in the routine. Again, this location has been hard-coded and should be modified to point to a directory on your local drive. It is assumed that there is only one file in this directory.
 
The purpose of this sample is to provide some code that you can adjust to suit your needs.

How to use

  1. Paste the code into VBA in ArcMap or ArcCatalog. The code can also be associated with a command click events in Visual Basic.
  2. Find the routine that performs the type of replica creation needed. To export a replica message you will need one of the export routines. To import the replica message on the child Geodataserver you will need to use one of the import routines
  3. Adjust the code appropriately and run the routine. The code below has hard coded server connections, input and output directories, dataset names and replica names.
[VBA]
'++ Exports a data change message (XML document) in compressed format (.ZIP) from a Replica. The geodatabase is
'++ accessed over the WAN.
'++ The relative replica needs to import this message to complete the message exchange.

Sub Export_ReplicaDataChanges_WAN()
    On Error GoTo eh
    Dim pGDSsource As IGeoDataServer
    Dim bOK As Boolean
    Dim scf As IAGSServerConnectionFactory
    Dim cprops As IPropertySet
    Dim psc As IAGSServerConnection
    Dim pSons As IAGSEnumServerObjectName
    Dim pSon As IAGSServerObjectName
    Dim pName As IName
    Dim pGDSData As IGDSData
    Dim sOutputDirectory As String
    Dim sOutputfile As String
    Dim sReplicaName As String
    Dim pGDSExportOptions As IGDSExportOptions
    Dim pRequest As WinHttpRequest
    Dim pByte() As Byte
    Dim lFileHandle As Long
    
    '++ Specify replica name and Output directory
    '++ Modify this values
    sReplicaName = "Test" '++ The name of your replica
    sOutputDirectory = "c:\temp\DataChanges_WAN" '++ The output location for your exported message
    
    '++ Get the server objects published on the the ArcGIS server named bobmk
    Set cprops = New PropertySet
    cprops.SetProperty "Machine", "bobmk"
    Set scf = New AGSServerConnectionFactory
    Set psc = scf.Open(cprops, 0)
    Set pSons = psc.ServerObjectNames
    pSons.Reset
    
    '++ Get the parent server object
    Set pSon = pSons.Next
    Do Until pSon.Name = "Jerome_5162_Wilt"
        Set pSon = pSons.Next
    Loop
    Set pName = pSon
    Set pGDSsource = pName.Open
    
    '++ Set the Export Options
    Set pGDSExportOptions = New GDSExportOptions
    pGDSExportOptions.ExportFormat = esriGDSExportFormatXml
    pGDSExportOptions.Compressed = True '++ Compressing generates a .ZIP
    pGDSExportOptions.BinaryGeometry = False
    
    Set pGDSData = pGDSsource.ExportReplicaDataChanges(sReplicaName, pGDSExportOptions, esriGDSTransportTypeUrl, esriExportGenerationsAll, False)
    
    '++ Replace or Create the Output Directory
    Dim pFSObject As Object
    Set pFSObject = CreateObject("Scripting.FileSystemObject")
    '++ If directory already exists - delete the folder and it's contents and recreate it
    If pFSObject.FolderExists(sOutputDirectory) Then
        pFSObject.DeleteFolder sOutputDirectory, True
    End If
    pFSObject.CreateFolder sOutputDirectory
    
    '++ Get the compressed replica workspace document file from the URL to the local output directory
    If pGDSData.TransportType = esriGDSTransportTypeUrl Then
        '++ if there is an output directory on the ArcGIS Server then the transport type will be URL
        Set pRequest = New WinHttpRequest
        pRequest.Open "GET", pGDSData.URL, False
        pRequest.Send
        
        If pRequest.Status <> 200 Then
            Debug.Assert False
            'make sure the virtual dir has anonymous access turned on
            '(win authentication works for IE, but not for WinHttp as used here)
            Err.Raise vbObjectError + pRequest.Status, "InternetUtils", pRequest.StatusText + " (" & pRequest.Status & ")"
        End If
        
        pByte() = pRequest.ResponseBody
        
        lFileHandle = FreeFile
        sOutputfile = sOutputDirectory & "\" & pFSObject.GetFileName(pGDSData.URL)
        Open sOutputfile For Binary Access Write As #lFileHandle
        Put #lFileHandle, , pByte
        Close lFileHandle
    Else '++ the file has been embedded b/c there is no output directory set on the ArcGIS Server
        MsgBox "The ArcGIS server has not been configured with an output directory" & _
            vbCrLf & "Replica data changes document was not created."
        Exit Sub
    End If
    
    MsgBox "Created data change message: " & _
        vbCrLf & "File Location: " & sOutputDirectory
    
    Exit Sub
eh:
    MsgBox "Exporting Replica Data Changes errored: " & Err.Description & " : error number: " & Err.Number
    
End Sub


'++ Exports an acknowledgement message from a Replica. The file is an XML file.  The geodatabase is
'++ accessed over the WAN.
'++ The relative replica needs to import this message to complete the message exchange.

Sub Export_Acknowledgement_WAN()
    On Error GoTo eh
    
    Dim pGDSsource As IGeoDataServer
    Dim bOK As Boolean
    Dim scf As IAGSServerConnectionFactory
    Dim cprops As IPropertySet
    Dim psc As IAGSServerConnection
    Dim pSons As IAGSEnumServerObjectName
    Dim pSon As IAGSServerObjectName
    Dim pName As IName
    Dim pGDSData As IGDSData
    Dim sOutputDirectory As String
    Dim sOutputfile As String
    Dim sReplicaName As String
    Dim pGDSExportOptions As IGDSExportOptions
    Dim pRequest As WinHttpRequest
    Dim pByte() As Byte
    Dim lFileHandle As Long
    
    '++ Specify replica name and Output Directory to that the File will be written to
    sReplicaName = "Test" '++ The name of your replica
    sOutputDirectory = "c:\temp\Acknowledgements_WAN" '++ The output location for your exported message
    
    '++ Get the server objects published on the the ArcGIS server named bobmk
    Set cprops = New PropertySet
    cprops.SetProperty "Machine", "bobmk"
    Set scf = New AGSServerConnectionFactory
    Set psc = scf.Open(cprops, 0)
    Set pSons = psc.ServerObjectNames
    pSons.Reset
    
    '++ Get the parent server object
    Set pSon = pSons.Next
    Do Until pSon.Name = "Jerome_5161_Wilt"
        Set pSon = pSons.Next
    Loop
    Set pName = pSon
    Set pGDSsource = pName.Open
    
    Set pGDSData = pGDSsource.ExportAcknowledgement(sReplicaName, esriGDSTransportTypeUrl)
    
    '++ Replace or Create the Output Directory
    Dim pFSObject As Object
    Set pFSObject = CreateObject("Scripting.FileSystemObject")
    '++ If directory already exists - delete it and recreate by copying
    'Force deletion of folder and contents if it exists
    If pFSObject.FolderExists(sOutputDirectory) Then
        pFSObject.DeleteFolder sOutputDirectory, True
    End If
    pFSObject.CreateFolder sOutputDirectory
    
    '++ Get the compressed replica workspace document file from the URL to the local output directory
    If pGDSData.TransportType = esriGDSTransportTypeUrl Then
        '++ if there is an output directory on the ArcGIS Server then the transport type will be URL
        Set pRequest = New WinHttpRequest
        pRequest.Open "GET", pGDSData.URL, False
        pRequest.Send
        
        If pRequest.Status <> 200 Then
            Debug.Assert False
            'make sure the virtual dir has anonymous access turned on
            '(win authentication works for IE, but not for WinHttp as used here)
            Err.Raise vbObjectError + pRequest.Status, "InternetUtils", pRequest.StatusText + " (" & pRequest.Status & ")"
        End If
        
        pByte() = pRequest.ResponseBody
        
        lFileHandle = FreeFile
        sOutputfile = sOutputDirectory & "\" & pFSObject.GetFileName(pGDSData.URL)
        Open sOutputfile For Binary Access Write As #lFileHandle
        Put #lFileHandle, , pByte
        Close lFileHandle
    Else '++ the file has been embedded b/c there is no output directory set on the ArcGIS Server
        MsgBox "The ArcGIS server has not been configured with an output directory" & _
            vbCrLf & "The acknowledgement file was not created."
        Exit Sub
    End If
    
    MsgBox "Created acknowledgement message: " & _
        vbCrLf & "File Location: " & sOutputfile
    
    Exit Sub
eh:
    MsgBox "Exporting acknowledgement errored: " & Err.Description & " : error number: " & Err.Number
End Sub


'++ Exports a data change message (XML document) in compressed format (.ZIP) from a Replica. The geodatabase is
'++ accessed over the LAN.
'++ The relative replica needs to import this message to complete the message exchange.

Sub Export_ReplicaDataChanges_LAN()
    On Error GoTo eh
    
    Dim pGDSsource As IGeoDataServer
    Dim pGDSsourceInit As IGeoDataServerInit
    Dim pGDSExportOptions As IGDSExportOptions
    Dim bOK As Boolean
    
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    
    '++ Specify replica name
    sReplicaName = "Test" '++ The name of your replica
    sOutputDirectory = "C:\temp\DataChanges_LAN" '++ The output location for your exported message
    
    '++ Initialize the parent
    Set pGDSsource = New GeoDataServer
    Set pGDSsourceInit = pGDSsource
    pGDSsourceInit.InitFromConnectionString "SERVER=jerome;INSTANCE=5162;VERSION=sde.DEFAULT;USER=wilt;PASSWORD=wilt;DATABASE=rep2"
    
    '++ Set the Export Options
    Set pGDSExportOptions = New GDSExportOptions
    pGDSExportOptions.ExportFormat = esriGDSExportFormatXml
    pGDSExportOptions.Compressed = True
    pGDSExportOptions.BinaryGeometry = False
    
    Set pGDSData = pGDSsource.ExportReplicaDataChanges(sReplicaName, pGDSExportOptions, esriGDSTransportTypeUrl, esriExportGenerationsAll, False)
    
    '++ Replace or Create the Output Directory and place output file in that location
    Dim pFSObject As Object
    Set pFSObject = CreateObject("Scripting.FileSystemObject")
    '++ If directory already exists - delete it and recreate by copying
    'Force deletion of folder and contents if it exists
    If pFSObject.FolderExists(sOutputDirectory) Then
        pFSObject.DeleteFolder sOutputDirectory, True
    End If
    pFSObject.CreateFolder sOutputDirectory
    pFSObject.CopyFile pGDSData.URL, sOutputDirectory & "\"
    
    MsgBox "Created data change message: " & _
        vbCrLf & "File Location: " & sOutputDirectory
    
    Exit Sub
eh:
    MsgBox "Exporting Replica Data Changes errored: " & Err.Description & " : error number: " & Err.Number
    
End Sub

'++ Exports an acknowledgement message from a Replica. The file is an XML file.
'++ The geodatabase isaccessed over the LAN.
'++ The relative replica needs to import this message to complete the message exchange.

Sub Export_Acknowledgement_LAN()
    On Error GoTo eh
    
    Dim pGDSsource As IGeoDataServer
    Dim pGDSsourceInit As IGeoDataServerInit
    Dim bOK As Boolean
    Dim sOutputfile As String
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    Dim sOutputDirectory As String
    
    '++ Specify replica name
    sReplicaName = "Test" '++ The name of your replica
    sOutputDirectory = "c:\temp\Acknowledgements_LAN" '++ The output location for your exported message
    
    '++ Initialize the parent
    Set pGDSsource = New GeoDataServer
    Set pGDSsourceInit = pGDSsource
    pGDSsourceInit.InitFromConnectionString "SERVER=jerome;INSTANCE=5161;VERSION=sde.DEFAULT;USER=wilt;PASSWORD=wilt;DATABASE=rep1"
    
    Set pGDSData = pGDSsource.ExportAcknowledgement(sReplicaName, esriGDSTransportTypeUrl)
    
    '++ Replace or Create the Output Directory and place output file in that location
    Dim pFSObject As Object
    Set pFSObject = CreateObject("Scripting.FileSystemObject")
    '++ If directory already exists - delete it and recreate by copying
    'Force deletion of folder and contents if it exists
    If pFSObject.FolderExists(sOutputDirectory) Then
        pFSObject.DeleteFolder sOutputDirectory, True
    End If
    pFSObject.CreateFolder sOutputDirectory
    pFSObject.CopyFile pGDSData.URL, sOutputDirectory & "\"
    
    MsgBox "Created acknowledgement message: " & _
        vbCrLf & "File Location: " & sOutputDirectory
    
    Exit Sub
eh:
    MsgBox "Exporting acknowledgement errored: " & Err.Description & " : error number: " & Err.Number
End Sub


'++ Imports a compressed data change message into a replica.
'++ The imported message is expected to be in compressed format (as is output of the export routine)
'++ The geodatabase is accessed over the LAN.

Sub Import_DataChanges_LAN()
    On Error GoTo eh
    
    Dim pGDStarget As IGeoDataServer
    Dim pGDStargetInit As IGeoDataServerInit
    Dim bOK As Boolean
    Dim sInputFile As String
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    Dim lFileLen As Long
    Dim lFileHandle As Long
    Dim bArray() As Byte
    
    '++ Specify replica name
    sReplicaName = "Test" '++ Modify this variable to be the name of your replica
    sInputDirectory = "c:\temp\Acknowledgements_LAN" '++ The directory that contains the Data changes file to be imported
    
    '++ Initialize the parent
    Set pGDStarget = New GeoDataServer
    Set pGDStargetInit = pGDStarget
    pGDStargetInit.InitFromConnectionString "SERVER=jerome;INSTANCE=5162;VERSION=sde.DEFAULT;USER=wilt;PASSWORD=wilt;DATABASE=rep2"
    
    '++ Get the ZIPPED message file in the specified input Directory
    Dim pFSO As Object 'FileSystemObject
    Dim pFiles As Object 'File
    Dim pFolder As Object
    Dim pFile As Object
    Dim sName As String
    Set pFSO = CreateObject("Scripting.FileSystemObject")
    Set pFolder = pFSO.GetFolder(sInputDirectory)
    Set pFiles = pFolder.Files
    For Each pFile In pFiles '++ Get the file in the directory - should only be one
        sName = pFile.Name
        Exit For
    Next
    
    '++ Read .zip file from the input directory into byte array to pass to the GDSData object
    lFileHandle = FreeFile
    sInputFile = sInputDirectory & "\" & sName
    Open sInputFile For Binary Access Read As #lFileHandle
    
    lFileLen = LOF(lFileHandle) ' returns byte count, 1-based
    lArrayMaxIndex = lFileLen - 1 ' array is 0-based
    ReDim bArray(lArrayMaxIndex)
    
    Get #lFileHandle, , bArray
    Close lFileHandle
    
    '++ Set the GDSData object
    Set pGDSData = New GDSData
    pGDSData.TransportType = esriGDSTransportTypeEmbedded
    pGDSData.Compressed = True
    pGDSData.EmbeddedData = bArray
    
    '++ Import the Acknowledgement File
    pGDStarget.ImportAcknowledgement pGDSData
    
    MsgBox "Successfully imported Data Changes to " & sReplicaName & _
        vbCrLf & "From File: " & sInputFile
    
    Exit Sub
eh:
    MsgBox "Importing Replica Data Changes errored: " & Err.Description & " : error number: " & Err.Number
End Sub


'++ Imports an acknowledgement message into a replica.  The geodatabase is
'++ accessed over the LAN.

Sub Import_Acknowledgement_LAN()
    On Error GoTo eh
    
    Dim pGDStarget As IGeoDataServer
    Dim pGDStargetInit As IGeoDataServerInit
    Dim bOK As Boolean
    Dim sInputFile As String
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    Dim lFileLen As Long
    Dim lFileHandle As Long
    Dim bArray() As Byte
    
    '++ Specify replica name
    sReplicaName = "Test" '++ Modify this variable to be the name of your replica
    sInputDirectory = "c:\temp\Acknowledgements_LAN" '++ The directory that contains the acknowledgement message to import
    
    '++ Initialize the parent
    Set pGDStarget = New GeoDataServer
    Set pGDStargetInit = pGDStarget
    pGDStargetInit.InitFromConnectionString "SERVER=jerome;INSTANCE=5162;VERSION=sde.DEFAULT;USER=wilt;PASSWORD=wilt;DATABASE=rep2"
    
    '++ Get the ZIPPED message file in the specified input Directory
    Dim pFSO As Object 'FileSystemObject
    Dim pFiles As Object 'File
    Dim pFolder As Object
    Dim pFile As Object
    Dim sName As String
    Set pFSO = CreateObject("Scripting.FileSystemObject")
    Set pFolder = pFSO.GetFolder(sInputDirectory)
    Set pFiles = pFolder.Files
    For Each pFile In pFiles '++ Get the file in the directory - should only be one
        sName = pFile.Name
        Exit For
    Next
    
    '++ Read .zip file from the input directory into byte array to pass to the GDSData object
    lFileHandle = FreeFile
    sInputFile = sInputDirectory & "\" & sName
    Open sInputFile For Binary Access Read As #lFileHandle
    
    lFileLen = LOF(lFileHandle) ' returns byte count, 1-based
    lArrayMaxIndex = lFileLen - 1 ' array is 0-based
    ReDim bArray(lArrayMaxIndex)
    
    Get #lFileHandle, , bArray
    Close lFileHandle
    
    '++ Set the GDSData object
    Set pGDSData = New GDSData
    pGDSData.TransportType = esriGDSTransportTypeEmbedded
    pGDSData.Compressed = False
    pGDSData.EmbeddedData = bArray
    
    '++ Import the Replica Message
    pGDStarget.ImportAcknowledgement
    MsgBox "Successfully imported acknowledgement to " & sReplicaName & _
        vbCrLf & "From File: " & sInputFile
    
    Exit Sub
eh:
    MsgBox "Importing Acknowledgement errored: " & Err.Description & " : error number: " & Err.Number
    
End Sub



'++ Imports an acknowledgement message into a replica.  The geodatabase is
'++ accessed over the WAN.

Sub Import_Acknowledgement_WAN()
    On Error GoTo eh
    
    Dim scf As IAGSServerConnectionFactory
    Dim cprops As IPropertySet
    Dim psc As IAGSServerConnection
    Dim pSons As IAGSEnumServerObjectName
    Dim pSon As IAGSServerObjectName
    Dim pName As IName
    Dim pGDStarget As IGeoDataServer
    Dim bOK As Boolean
    Dim sInputFile As String
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    Dim lFileLen As Long
    Dim lFileHandle As Long
    Dim bArray() As Byte
    
    '++ Specify replica name
    sReplicaName = "Test" '++ The name of your replica
    sInputDirectory = "c:\temp\Acknowledgements_WAN" '++ The directory that contains the acknowledgement file to be imported
    
    '++ Get the server objects published on the the ArcGIS server named bobmk
    Set cprops = New PropertySet
    cprops.SetProperty "Machine", "bobmk"
    Set scf = New AGSServerConnectionFactory
    Set psc = scf.Open(cprops, 0)
    Set pSons = psc.ServerObjectNames
    pSons.Reset
    
    '++ Get the parent server object
    Set pSon = pSons.Next
    Do Until pSon.Name = "Jerome_5162_Wilt"
        Set pSon = pSons.Next
    Loop
    Set pName = pSon
    Set pGDStarget = pName.Open
    
    '++ Get the ZIPPED message file in the specified input Directory
    Dim pFSO As Object 'FileSystemObject
    Dim pFiles As Object 'File
    Dim pFolder As Object
    Dim sName As String
    Set pFSO = CreateObject("Scripting.FileSystemObject")
    Set pFolder = pFSO.GetFolder(sInputDirectory)
    Set pFiles = pFolder.Files
    For Each pFile In pFiles '++ Get the only file in the directory
        sName = pFile.Name
        Exit For
    Next
    
    '++ Read .zip file from the input directory into byte array to pass to the GDSData object
    lFileHandle = FreeFile
    sInputFile = sInputDirectory & "\" & sName
    Open sInputFile For Binary Access Read As #lFileHandle
    
    lFileLen = LOF(lFileHandle) ' returns byte count, 1-based
    lArrayMaxIndex = lFileLen - 1 ' array is 0-based
    ReDim bArray(lArrayMaxIndex)
    
    Get #lFileHandle, , bArray
    Close lFileHandle
    
    '++ Set the GDSData object
    Set pGDSData = New GDSData
    pGDSData.TransportType = esriGDSTransportTypeEmbedded
    pGDSData.Compressed = False
    pGDSData.EmbeddedData = bArray
    
    '++ Import the Replica Message
    pGDStarget.ImportAcknowledgement pGDSData
    
    MsgBox "Successfully imported Acknowledgement to " & sReplicaName & _
        vbCrLf & "From File: " & sInputFile
    
    Exit Sub
eh:
    MsgBox "Importing Acknowledgement errored: " & Err.Description & " : error number: " & Err.Number
    
End Sub

'++ Imports a compressed data change message into a replica.
'++ The imported message is expected to be in compressed format (.ZIP)
'++ The geodatabase is accessed over the WAN.

Sub Import_DataChange_WAN()
    On Error GoTo eh
    
    Dim scf As IAGSServerConnectionFactory
    Dim cprops As IPropertySet
    Dim psc As IAGSServerConnection
    Dim pSons As IAGSEnumServerObjectName
    Dim pSon As IAGSServerObjectName
    Dim pName As IName
    Dim pGDStarget As IGeoDataServer
    Dim bOK As Boolean
    Dim sInputFile As String
    Dim pGDSData As IGDSData
    Dim sReplicaName As String
    Dim lFileLen As Long
    Dim lFileHandle As Long
    Dim bArray() As Byte
    
    '++ Specify replica name
    sReplicaName = "Test" '++ The name of your replica
    sInputDirectory = "c:\temp\DataChanges_WAN" '++ The directory that contains the Data changes file (ZIP) to be imported
    
    '++ Get the server objects published on the the ArcGIS server named bobmk
    Set cprops = New PropertySet
    cprops.SetProperty "Machine", "bobmk"
    Set scf = New AGSServerConnectionFactory
    Set psc = scf.Open(cprops, 0)
    Set pSons = psc.ServerObjectNames
    pSons.Reset
    
    '++ Get the parent server object
    Set pSon = pSons.Next
    Do Until pSon.Name = "Jerome_5161_Wilt"
        Set pSon = pSons.Next
    Loop
    Set pName = pSon
    Set pGDStarget = pName.Open
    
    '++ Get the ZIPPED message file in the specified input Directory
    Dim pFSO As Object 'FileSystemObject
    Dim pFiles As Object 'File
    Dim pFolder As Object
    Dim pFile As Object
    Dim sName As String
    Set pFSO = CreateObject("Scripting.FileSystemObject")
    Set pFolder = pFSO.GetFolder(sInputDirectory)
    Set pFiles = pFolder.Files
    For Each pFile In pFiles '++ Get the file in the directory - should only be one
        sName = pFile.Name
        Exit For
    Next
    
    '++ Read .zip file from the input directory into byte array to pass to the GDSData object
    lFileHandle = FreeFile
    sInputFile = sInputDirectory & "\" & sName
    Open sInputFile For Binary Access Read As #lFileHandle
    
    lFileLen = LOF(lFileHandle) ' returns byte count, 1-based
    lArrayMaxIndex = lFileLen - 1 ' array is 0-based
    ReDim bArray(lArrayMaxIndex)
    
    Get #lFileHandle, , bArray
    Close lFileHandle
    
    '++ Set the GDSData object
    Set pGDSData = New GDSData
    pGDSData.TransportType = esriGDSTransportTypeEmbedded
    pGDSData.Compressed = True
    pGDSData.EmbeddedData = bArray
    
    '++ Import the Replica Message
    pGDStarget.ImportReplicaDataChanges esriGDSReplicaImportSourceDeltaXmlFile, esriReplicaDetectConflicts, True, pGDSData
    
    MsgBox "Successfully imported Data Changes to " & sReplicaName & _
        vbCrLf & "From File: " & sInputFile
    
    Exit Sub
eh:
    MsgBox "Importing Replica Data Changes errored: " & Err.Description & " : error number: " & Err.Number
    
End Sub