by1455的自留地

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

有时侯需要批量拷贝一些文件到sharepoint 2010的档案库,sharepoint feature solution 可以简单的完成

 

例如要把 hi.docx,sample.txt 拷贝到 hiweb.contoso.com 和 intranet.contoso.com 下的 shared documents.

 

如下步骤:

 

在 SPS2010 的系统路径的 features 下 新开一个文件夹 filepush

生成一个 feature.xml 文件, 内容如下

<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="524ED45F-C546-462D-A85F-34E8CC5CF5CC" Title="Demo.20100824" Scope="Web">
                 <ElementManifests>
                          <ElementManifest Location="elements.xml" />
                  </ElementManifests>
  </Feature>

 

再生成一个 elements.xml 文件, 内容如下

<?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" />
        <File Url="Hi.docx" Type="GhostableInLibrary" />
    </Module>
</Elements>

然后再把hi.docx和sample.txt拷贝进来。

image

生成一个命令行文件 push.cmd, 内容如下

stsadm -o uninstallfeature -n filepush -force
stsadm -o installfeature -n filepush
stsadm" -o activatefeature -n filepush -url "http://intranet.contoso.com/" –force

stsadm" -o activatefeature -n filepush -url http://hiweb.contoso.com/ -force

 

结果

image

 

注意如果同名文件已经存在,推送会失败,也就是同名文件不会被替换。

posted on 2010-08-31 11:36  by1455  阅读(231)  评论(0编辑  收藏  举报