Abdullah Quzmar

Abdullah Quzmar

  • 1.8k
  • 6
  • 203

Getting the row value from shapefile to featureclass(Arcobj)

Jul 10 2019 11:32 PM
Hello guys
 
I have a shapefile and I want to read the attribute value but row by row not filed by field !
 
Because I want to put each row value on the featureclass object (insertion) without using featurelayer object . You can see my code below I tried to use featurebuffer,featurecursor but I didn't make it successfully .Please anyone help me ,Thank you
  1. for(int i=0;i< distincfiles.length;i++)  
  2. IWorkspaceFactory pwsf = new ShapefileWorkspaceFactory();  
  3. IWorkspace pws = pwsf.OpenFromFile(distincfiles[i], 0);  
  4. IEnumDataset pEnumDs = pws.Datasets[esriDatasetType.esriDTAny];  
  5. IDataset pds = pEnumDs.Next();  
  6. // ShapeDetail shap = null;  
  7. while (pds != null)  
  8. {  
  9. string name = pds.Name;  
  10. string shapeGeomType = "Unknown";  
  11. IFeatureClass pfc = (IFeatureClass)pds;  
  12. IFields C = pfc.Fields;  
  13. int s = pfc.Fields.FieldCount;  
  14. esriGeometryType shp = pfc.ShapeType;  
  15. if (shp == esriGeometryType.esriGeometryPolyline)  
  16. {  
  17. shapeGeomType = "Polyline";  
  18. }  
  19. if (shp == esriGeometryType.esriGeometryLine)  
  20. {  
  21. shapeGeomType = "Line";  
  22. }  
  23. if (shp == esriGeometryType.esriGeometryMultipoint || shp == esriGeometryType.esriGeometryPoint)  
  24. {  
  25. shapeGeomType = "Point";  
  26. }  
  27. if (shp == esriGeometryType.esriGeometryPolygon)  
  28. {  
  29. shapeGeomType = "Polygon";  
  30. }  
  31. int cntFeat = pfc.FeatureCount(null);  
  32. dataGridView1.Rows.Add(name, CategoryName, cntFeat, missingfieldstatus.ToString());  
  33. pds = pEnumDs.Next();  
  34. // MessageBox.Show(NumMissingField + " " + "count of missing fields");// put it on the log  
  35. }  
  36. }  
  37. }  
  38. dataGridView1.Visible = true;  
  39. }