开发者

Sharepoint 2010 - Feature(Module) Cannot copy sample.txt to "Shared Documents" on web

I am making a feature in sharepoint 2010 foundation and the procedure is below:

1- I created a empty c# project in visual studio and made 3 files in their (feature.xml, elements.xml and sample.txt) (it has been made to copy the sample.txt file to "Shared Documents library"

2- I copied the three files in the 14 Hive features folder in my new folder named "demofeature"

3- I ran command to install the feature which is (stsadm -o installfeature -name demofeature) it ran successfully

4- I am now able to see my feature in (site settings > manage features page) the site/web and I activated it from there

5- I went to shared documents but I cannot see my file there i.e: sample.txt and also I didnt see any errors during the deployment.

Please let me know, what can be wrong here?

I am pasting my code below :

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>

elements.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>

and a sample.txt file which is placed in the new feature folder.

Thanks Raj


I would highly suggest using Visual Studio 2010 for creating your features and modules. Otherwise, it is only a high priced text editor. From the menu, select Project > Add New Item, then select Module from the SharePoint 2010 templates. This would generate all of the XML for you correctly.

To your question, try the following 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>

The elements.xml file must be in an ElementManifest element, not an ElementFile element.

<?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>

Having a Path attribute in the Module element means that SharePoint will search a Shared Documents folder within your feature for all files (which does not exist).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜