SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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", 
                             SPListTemplateType.DocumentLibrary);

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

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

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;
list.Update();

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

share|improve this answer

Your Answer

 
discard

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.