且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将内容类型添加到所有文档库

更新时间:2023-02-08 19:36:26

进行更多调查后,我发现通过更改..\12\TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml可以将链接到文档"内容类型添加到所有新文档库中.更改schema.xml,然后执行IISRESET不会更改现有的库.

After doing some more investigation, I found out that by changing ..\12\TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml I could add the Link to a Document content type to all NEW document libraries. Changing the schema.xml and then doing an IISRESET did not change existing libraries.

为此,我的schema.xml的开始看起来像这样:

In order to do this, the beginning of my schema.xml looked something like this:

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="$Resources:shareddocuments_Title;" Direction="$Resources:Direction;" Url="Shared Documents" BaseType="1" EnableContentTypes="TRUE">
  <!-- Link to Document Content Type - Added EnableContentTypes="TRUE" -->
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x0101">
        <Folder TargetName="Forms/Document" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
      <!-- Link to Document Content Type -->
      <ContentTypeRef ID="0x01010A" />
    </ContentTypes>

由于这不会更改现有文档库,因此我需要编写一个控制台应用程序,该应用程序使用其他两个答案中指定的代码来更新每个库.

Since this didn't change existing document libraries, I will need to write a console application that uses the code specified in the other two answers to update each library.