【问题标题】:Sharepoint 2010 - Feature(Module) Cannot copy sample.txt to "Shared Documents" on webSharepoint 2010 - 功能(模块)无法将 sample.txt 复制到网络上的“共享文档”
【发布时间】:2013-09-24 15:17:48
【问题描述】:

我正在sharepoint 2010基础中制作一个功能,过程如下:

1- 我在 Visual Studio 中创建了一个空的 c# 项目,并在其(feature.xml、elements.xml 和 sample.txt)中创建了 3 个文件(已将 sample.txt 文件复制到“共享文档库” "

2- 我将 14 Hive features 文件夹中的三个文件复制到名为“demofeature”的新文件夹中

3- 我运行命令来安装它成功运行的功能 (stsadm -o installfeature -name demofeature)

4- 我现在可以在网站/网站(网站设置 > 管理功能页面)中看到我的功能,并从那里激活它

5- 我去了共享文档,但在那里看不到我的文件,即:sample.txt,而且在部署过程中我也没有看到任何错误。

请告诉我,这里有什么问题?

我在下面粘贴我的代码:

feature.xml

    <?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
         Id="2BAC8ED9-3CFF-4922-9E4F-81F8AD9500F9"
         Scope="Web"
         Title="RHM test feature" >

  <ElementManifests>
    <ElementFile Location="elements.xml"/>
    <ElementFile Location="Sample.txt"/>
  </ElementManifests>
</Feature>

元素.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >

  <Module Name="Deploy" Url="Shared Documents" Path="Shared Documents" >
    <File Url="Sample.txt" Type="GhostableInLibrary" Path="Sample.txt">
          </File>    
  </Module>
</Elements>

以及放置在新功能文件夹中的 sample.txt 文件。

谢谢 拉杰

【问题讨论】:

    标签: asp.net sharepoint-2010


    【解决方案1】:

    我会强烈建议使用 Visual Studio 2010 来创建您的功能和模块。否则,它只是一个高价的文本编辑器。从菜单中选择项目 > 添加新项目,然后从 SharePoint 2010 模板中选择模块。这将为您正确生成所有 XML。

    对于您的问题,请尝试以下 XML:

    <?xml version="1.0" encoding="utf-8" ?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
             Id="2BAC8ED9-3CFF-4922-9E4F-81F8AD9500F9"
             Scope="Web"
             Title="RHM test feature" >
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
        <ElementFile Location="Sample.txt"/>
      </ElementManifests>
    </Feature>
    

    elements.xml 文件必须在 ElementManifest 元素中,而不是在 ElementFile 元素中。

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
      <Module Name="Deploy" Url="Shared Documents">
        <File Url="Sample.txt" Type="GhostableInLibrary" Path="Sample.txt">
        </File>    
      </Module>
    </Elements>
    

    在 Module 元素中具有 Path 属性意味着 SharePoint 将在您的功能内的共享文档文件夹中搜索所有文件(不存在)。

    【讨论】:

    • 让我试试你的建议,让你知道结果。
    • 是的,它成功了,感谢百万富翁 Bennema :) 你太棒了。
    猜你喜欢
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多