CReplicationProject.EnumItems Method

Retrieves the items that are contained in a source directory for the Commerce Server Staging (CSS) project. The CReplicationItem object provides information about specific files to be replicated.

object EnumItems(string directory, ref object iterator)

Parameters

  • directory
    Relative path of the directory that contains the items to be enumerated.

  • iterator
    Used by the CSS service to enumerate the list of items. This value should be initialized to 0 (zero) and should not be modified.

Return Value

A CReplicationItem object for this iteration.

Remarks

You must have CSS administrator rights to call this method.

The EnumItems method is valid only for Web content and Internet Information Server (IIS) metabase projects.

This method returns a CReplicationItem object for each item that is found in the specified directory, until all items have been enumerated. This method enumerates files for standard projects and containers for metabase projects.

This method sets the value of e.ErrorCode to -2147422485 (“No more items.”) to indicate the end of the enumeration.

The CReplicationProject.EnumItems method corresponds to the COM method named ReplicationProject.EnumItems.

Example

The following example displays the names of the replication items in the \LocalRep directory for the Web content project named Project1.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("");
  CReplicationProject replicationProject;
  replicationProject =   (CReplicationProject)replicationServer.OpenProject("Project1", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
  string directory = @".\LocalRep";
  Console.WriteLine("The following items were replicated from {0}", directory);
  int iterator = 0;
  object i = iterator as object;
    while (true)
      {
        try
          {
            // Get the next replication item
            CReplicationItem item = (CReplicationItem)replicationProject.EnumItems(directory, ref i);
            Console.WriteLine(item.Name);
         }
         catch (System.Runtime.InteropServices.COMException e)
         {
       // Exit if "No more items" error
       if (e.ErrorCode == -2147422485)
              break;
         else
              throw e;
          }
      }

See Also

Other Resources

Projects

How to Retrieve Project Information

CReplicationItem Class

CReplicationProject Class