How To list Fileds of a Shapefile and Add New Field using C# & ArcObjects

2963
3
07-22-2012 05:26 PM
BernardoG_
New Contributor II
Hi,
Can someone please help me to figure out how to get list of attribute fields name from a shapefile? For example , let's say I have a shapefile called "NewDH.shp" stored at "D://GIS" how I can list the attributes(field's name).
I also appreciate if you can let me know how I can add a new field to the above mentioned shapefile suing C#

I think this is the best way to understand how Arcobjects work with c#.

Regards,
Reply
0 Kudos
3 Replies
KenBuja
MVP Honored Contributor
A good place to learn how to work with C# and ArcObjects is in the Online help documentation.

This page contains the code to list the fields and all their properties

Here's how to add a field to a dataset.

There are also a number of ArcGIS snippets available in Visual Studios, such as this one that opens a shapefile from a path and file name
Reply
0 Kudos
BernardoG_
New Contributor II
Hi kenbuja,

Thanks for perfect links.I just have a quick question here,
the link for Creating fields is perfect and thanks for that but as I mentioned I do not know how I can add this field to a specific EXISTING shapefile. I really have problem with this part.Honestly I do not know how to navigate to an exiting file(shapefile) and add the fields there!
Can you please let me know how I can do this?

Regards,
Reply
0 Kudos
LeoDonahue
Regular Contributor
Connecting to a shapefile workspace.

It does require some modification to that first code sample.

Or, you could do as Ken suggested and read the online help and find the section in the help that shows you all of the code snippets, and use the code snippet to open a shapefile workspace.
Reply
0 Kudos