I’m programatically changing the content type of a document in a document library. But document is getting added with the content type only.
Here is my coding:
SPFile ofile = oweb.GetFile(oweb.Url + '/' + oDocSet.Item.Url + '/' + refName);
ofile.Item["Content Type"] = octype.Name;
ofile.Item["Content Type ID"] = octype.Id;
ofile.Item.Update();
when i traced the above coding the content type is getting changed when i assign them to the item but after I update the the item in the last line the content type of the item is getting set to the default content type.
Shouldn’t it be:
Note the lack of spaces in the field names
P.S.: Is the content type actually allowed in the library?