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);
<SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">ConvertLabelsToGDBAnnotationEntireMap</SPAN><SPAN class="punctuation token">(</SPAN>IMap pMap<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">bool</SPAN> featureLinked<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IConvertLabelsToAnnotation pConvertLabelsToAnnotation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN>
<SPAN class="token class-name">ConvertLabelsToAnnotationClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
ITrackCancel pTrackCancel <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">CancelTrackerClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Change global level options for the conversion by sending in different parameters to the next line.</SPAN>
pConvertLabelsToAnnotation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Initialize</SPAN><SPAN class="punctuation token">(</SPAN>pMap<SPAN class="punctuation token">,</SPAN>
esriAnnotationStorageType<SPAN class="punctuation token">.</SPAN>esriDatabaseAnnotation<SPAN class="punctuation token">,</SPAN>
esriLabelWhichFeatures<SPAN class="punctuation token">.</SPAN>esriVisibleFeatures<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN> pTrackCancel<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IUID pUID <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">UIDClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
pUID<SPAN class="punctuation token">.</SPAN>Value <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//IGeoFeatureLayer interface ID.</SPAN>
IMapLayers pMapLayers <SPAN class="operator token">=</SPAN> pMap <SPAN class="keyword token">as</SPAN> IMapLayers<SPAN class="punctuation token">;</SPAN>
IEnumLayer pEnumLayer <SPAN class="operator token">=</SPAN> pMapLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">get_Layers</SPAN><SPAN class="punctuation token">(</SPAN>pUID <SPAN class="keyword token">as</SPAN> UIDClass<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Reset</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IGeoFeatureLayer pGeoFeatureLayer <SPAN class="operator token">=</SPAN> pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">as</SPAN> IGeoFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>Valid <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pMapLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">IsLayerVisible</SPAN><SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer <SPAN class="keyword token">as</SPAN> ILayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">//Takes scale and groups layers into account.</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>DisplayAnnotation <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IFeatureClass pFeatureClass <SPAN class="operator token">=</SPAN> pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">;</SPAN>
IDataset pDataset <SPAN class="operator token">=</SPAN> pFeatureClass <SPAN class="keyword token">as</SPAN> IDataset<SPAN class="punctuation token">;</SPAN>
IFeatureWorkspace pFeatureWorkspace <SPAN class="operator token">=</SPAN> pDataset<SPAN class="punctuation token">.</SPAN>Workspace <SPAN class="keyword token">as</SPAN>
IFeatureWorkspace<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Add the layer information to the converter object. Specify the parameters of the output annotation feature class here as well.</SPAN>
pConvertLabelsToAnnotation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddFeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer<SPAN class="punctuation token">,</SPAN>
pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">+</SPAN> <SPAN class="string token">"_Anno"</SPAN><SPAN class="punctuation token">,</SPAN> pFeatureWorkspace<SPAN class="punctuation token">,</SPAN>
pFeatureClass<SPAN class="punctuation token">.</SPAN>FeatureDataset<SPAN class="punctuation token">,</SPAN> featureLinked<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
pGeoFeatureLayer <SPAN class="operator token">=</SPAN> pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">as</SPAN> IGeoFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">//Do the conversion.</SPAN>
pConvertLabelsToAnnotation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConvertLabels</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IEnumLayer pAnnoEnumLayer <SPAN class="operator token">=</SPAN> pConvertLabelsToAnnotation<SPAN class="punctuation token">.</SPAN>AnnoLayers<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Turn off labeling for the layers converted.</SPAN>
pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Reset</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
pGeoFeatureLayer <SPAN class="operator token">=</SPAN> pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">as</SPAN> IGeoFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>Valid <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pMapLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">IsLayerVisible</SPAN><SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer <SPAN class="keyword token">as</SPAN> ILayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">//Takes scale and groups layers into account.</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>DisplayAnnotation <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN>
pGeoFeatureLayer<SPAN class="punctuation token">.</SPAN>DisplayAnnotation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
pGeoFeatureLayer <SPAN class="operator token">=</SPAN> pEnumLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">as</SPAN> IGeoFeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">//Add the result annotation layer to the map.</SPAN>
pMap<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddLayers</SPAN><SPAN class="punctuation token">(</SPAN>pAnnoEnumLayer<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Refresh the map to update the display.</SPAN>
IActiveView pActiveView <SPAN class="operator token">=</SPAN> pMap <SPAN class="keyword token">as</SPAN> IActiveView<SPAN class="punctuation token">;</SPAN>
pActiveView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Refresh</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>