When I try to add a File type field to a custom list I get
System.InvalidOperationException: Operation is not valid due to the current state of the object
Guid listGuid = adminWeb.Lists.Add(queueListName, "DotNetNuke Document Queue", SPListTemplateType.GenericList);
queueList = adm开发者_StackOverflowinWeb.Lists[listGuid];
queueList.Fields.Add("Status", SPFieldType.File, false);
queueList.Update();
I don't believe that you can have a "File" field. If you look in the UI, there is no "File" field type for custom/generic list.
If you need 1 file per item and it is mandatory, then you should be using a document library.
If you need more than 1 file per list item, then file attachments is the way to go.
精彩评论