Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

creating a Field of type File and Attachments in document library and getting exception error as mentioned above.Please help me out thanks in advance..

Guid listid1 = web.Lists.Add("TESTLIBRARY", "THIS LIST IS FOR TESTING", 

SPList documentlibrary = web.Lists["TESTLIBRARY"];
documentlibrary.ContentTypesEnabled = true;

documentlibrary.Fields.Add("Employee Attachments", SPFieldType.File, false);
share|improve this question

1 Answer 1

Having attachments on document libraries and surveys is not supported.

In addition, you don't add an attachments column to a list in general. The way to enable attachments is to set the EnableAttachments property on a list to true.

SPList list = web.Lists["LISTNAME"]; 
list.EnableAttachments = true;

The code above will throw an exception if the list is a document library or survey

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.