I am trying to convert labels to annotation by using following code.It is working fine and creating annotation in the feature layers database but i want to store in other Geodatabase.
I have tried by adding string path of my geodatabase as a workspace but it is not working.Convert Annotation
string fgdb= folderPath + "\\Test.gdb;
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(fgdb, 0);
static void ConvertLabelsToGDBAnnotationEntireMap(IMap pMap, bool featureLinked)
{
IConvertLabelsToAnnotation pConvertLabelsToAnnotation = new
ConvertLabelsToAnnotationClass();
ITrackCancel pTrackCancel = new CancelTrackerClass();
pConvertLabelsToAnnotation.Initialize(pMap,
esriAnnotationStorageType.esriDatabaseAnnotation,
esriLabelWhichFeatures.esriVisibleFeatures, true, pTrackCancel, null);
IUID pUID = new UIDClass();
pUID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
IMapLayers pMapLayers = pMap as IMapLayers;
IEnumLayer pEnumLayer = pMapLayers.get_Layers(pUID as UIDClass, true);
pEnumLayer.Reset();
IGeoFeatureLayer pGeoFeatureLayer = pEnumLayer.Next()as IGeoFeatureLayer;
while (pGeoFeatureLayer != null)
{
if (pGeoFeatureLayer.Valid == true)
{
if (pMapLayers.IsLayerVisible(pGeoFeatureLayer as ILayer))
{
if (pGeoFeatureLayer.DisplayAnnotation == true)
{
IFeatureClass pFeatureClass = pGeoFeatureLayer.FeatureClass;
IDataset pDataset = pFeatureClass as IDataset;
IFeatureWorkspace pFeatureWorkspace = pDataset.Workspace as
IFeatureWorkspace;
pConvertLabelsToAnnotation.AddFeatureLayer(pGeoFeatureLayer,
pGeoFeatureLayer.Name + "_Anno", pFeatureWorkspace,
pFeatureClass.FeatureDataset, featureLinked, false, false,
true, true, "");
}
}
}
pGeoFeatureLayer = pEnumLayer.Next()as IGeoFeatureLayer;
}
pConvertLabelsToAnnotation.ConvertLabels();
IEnumLayer pAnnoEnumLayer = pConvertLabelsToAnnotation.AnnoLayers;
pEnumLayer.Reset();
pGeoFeatureLayer = pEnumLayer.Next()as IGeoFeatureLayer;
while (pGeoFeatureLayer != null)
{
if (pGeoFeatureLayer.Valid == true)
{
if (pMapLayers.IsLayerVisible(pGeoFeatureLayer as ILayer))
{
if (pGeoFeatureLayer.DisplayAnnotation == true)
pGeoFeatureLayer.DisplayAnnotation = false;
}
}
pGeoFeatureLayer = pEnumLayer.Next()as IGeoFeatureLayer;
}
pMap.AddLayers(pAnnoEnumLayer, true);
IActiveView pActiveView = pMap as IActiveView;
pActiveView.Refresh();
}