How to drop a representation by coding?

3312
1
12-03-2014 05:20 AM
ZengHongyun
New Contributor II

Hi,I want to drop a reprentation in a geodatabase,and I use the DropRepresentation Geoprocessoring tool in C#,the code is following:

private bool RemoveRepresentation(IRepresentationWorkspaceExtension pRepWksExt,IFeatureClass pFeatureClass)

{

     IEnumDatasetName enumDatasetName = pRepWksExt.get_FeatureClassRepresentationNames(pFeatureClass);

     enumDatasetName.Reset();

      IDatasetName pDatasetName = enumDatasetName.Next();

     ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();

 

 

     while (pDatasetName != null)

      {

          try

           {

               DropRepresentation dropRep = new DropRepresentation();

               dropRep.representation = pDatasetName.Name;

               dropRep.in_features = pFeatureClass;

               gp.Execute(dropRep, null);

           }

          catch (Exception ex)

          { return false; }

 

           pDatasetName = enumDatasetName.Next();

     }

          return true;

}

but in the line of gp.Execute(dropRep, null), it failed,the error code is -2147467259,HRESULT E_FAIL。 help! thanks!

0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor

In the help for this geo-processing tool it sets the workspace in the sample code, try doing that?

0 Kudos