Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 无法更改文档库中文档列表项的内容类型_List_Sharepoint_Types - Fatal编程技术网

List 无法更改文档库中文档列表项的内容类型

List 无法更改文档库中文档列表项的内容类型,list,sharepoint,types,List,Sharepoint,Types,我正在通过编程更改文档库中文档的内容类型。但文档仅添加了内容类型 这是我的代码: 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(); 当我跟踪上述编码时,当我将内容类型分配给项目

我正在通过编程更改文档库中文档的内容类型。但文档仅添加了内容类型

这是我的代码:

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();
当我跟踪上述编码时,当我将内容类型分配给项目时,内容类型正在更改,但在我更新最后一行中的项目后,项目的内容类型将设置为默认内容类型。

是否应该:

SPFile ofile = oweb.GetFile(oweb.Url + '/' + oDocSet.Item.Url + '/' + refName); 
ofile.Item["ContentType"] = octype.Name; 
ofile.Item["ContentTypeId"] = octype.Id; 
ofile.Item.Update(); 
注意字段名中缺少空格


注意:库中是否允许使用内容类型?

我的情况与这里描述的相同。将文档以自定义格式保存到文档库中后,ContentType保持不变。上面提供的代码运行时没有异常和消息,但contenttype保持不变

通过恢复为默认编辑表单、使用该表单更改contenttype并再次在Sharepoint Designer中重新指定自定义编辑表单,问题得以解决。现在contenttype更改可以正常工作了


可能是sharepoint的内部错误。

只是想让您知道这个答案修复了我在以编程方式更改文档类型方面的问题。我没有在该库中启用内容类型