AnsweredAssumed Answered

Checking for existing fields before adding

Question asked by kyanuk1 on Oct 4, 2012
Latest reply on Oct 4, 2012 by kyanuk1
Hello -

I am trying to check whether a field exists before attempting to create it.  The code I have so far is:

private void CreateField(IDataset d, IFeatureClass f, string name, string alias)         {             // IF FIELD DOES NOT EXIST, RETURN, ELSE, CREATE              IField field = new FieldClass();             IFieldEdit fe = (IFieldEdit)field;             fe.Name_2 = name;             fe.AliasName_2 = alias;             fe.Type_2 = esriFieldType.esriFieldTypeString;             fe.Length_2 = 20;             Invoke(new MethodInvoker(delegate { UpdateLabel.Text = "Creating field " + field.Name + "\nfor " + d.Name.Split('.')[1] + "... "; }));             f.AddField(field);         }



Thanks,

Kevin

Outcomes