feature class create new feature problem

Discussion created by shannonwhite on Apr 18, 2011
Latest reply on Apr 18, 2011 by shannonwhite
Hi All, I am trying to copy the spatial component of a existing feature layer to a new Feature Class inside a file geodatabase.  I have set up the new feature class and created the fields that I would like.  When I create new features for the feature class using the IFeatureClass.CreateFeature, all of the shapes of the new features are the same, even though all other fields are copied correctly with different values for the appropriate features.  Not sure what I am doing wrong since I am using code that worked previous for 9.3.  Stepping through the code I received changing envelopes for each selected feature but it seems that the last shape of the feature cursor is the one that is applied to all new features, even though all all attributes are calculated and stored properly.  Any help would be appreciated, Thanks!

I have attached code below for comments

private bool AddSelectedRecordsToNewFeatureClass(IFeatureLayer pSelFLayer, IWorkspace pWorkspace, IFeatureClass pNewFC)

            IWorkspaceEdit pWSE = (IWorkspaceEdit)pWorkspace;


                //calculate records for the newFeatClass using the selection set from the selected layer
                //the fields that have to be calculated is shape, accode and site, yearcut

                IFeatureSelection pFeatureSelection = pSelFLayer as IFeatureSelection;

                if (pFeatureSelection.SelectionSet.Count == 0)
                    MessageBox.Show("Did not find selected Features");
                    return false;

                ICursor pCursor = null;
                pFeatureSelection.SelectionSet.Search(null, true, out pCursor);
                IFeatureCursor pFeatCursor = pCursor as IFeatureCursor;

                IFeature pFeat = pFeatCursor.NextFeature();               
                ESRI.ArcGIS.Geometry.IGeometry pGeometry = null;
                //start editing
                IFeature pNewFeat = null; ;

                while (pFeat != null)

                    pGeometry = pFeat.Shape;
                    pNewFeat = pNewFC.CreateFeature();
                    pNewFeat.Shape = pGeometry;

                    pNewFeat.set_Value(pNewFeat.Fields.FindField("ACCODE"), pFeat.get_Value(pFeat.Fields.FindField("ACCODE")));
                    pNewFeat.set_Value(pNewFeat.Fields.FindField("SITE"), pFeat.get_Value(pFeat.Fields.FindField("SITE")));


                    pFeat = pFeatCursor.NextFeature();



                return true;

            catch (Exception ex)

                return false;