首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Sharepoint品牌推广-多文件资源调配

Sharepoint品牌推广-多文件资源调配
EN

Stack Overflow用户
提问于 2009-08-12 19:09:42
回答 2查看 1.9K关注 0票数 3

我在sharepoint中创建了一个自定义的母版页,里面有很多图片(比如200张)。如何打包要设定到网站集的样式库的所有文件?据我所知,唯一的方法是通过一个特性,但这意味着将每个文件(总共200个)作为一个<file></file>元素列出。有没有更简单的方法?属性IncludeFolders=“??-?”在<module></module>中似乎什么也做不了。

如果所有图像文件都位于我的要素文件夹(例如...\template\features\myFeature\images)内的某个文件夹中,是否可以将整个文件夹配置到样式库?

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-08-12 21:10:17

此module.xml文件位于名为"Images“的文件夹中。所有图片也都在此文件夹中(使用sharepoint开发工具for visual studio 2008 v1.3)。wsp包需要知道正在添加的所有文件,因此您必须添加每个文件。(将.wsp重命名为.cab并将其打开。然后,您可以看到解决方案中的所有文件)

代码语言:javascript
运行
复制
 <Elements Id="8f8113ef-75fa-41ef-a0a2-125d74fc29b7" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Images" Url="Style Library/Images/myfolder" RootWebOnly="TRUE">
    <File Path="hvi_logo.bmp" Url="hvi_logo.bmp" Type="GhostableInLibrary" />
    <File Path="hvi_logo_small.bmp" Url="hvi_logo_small.bmp" Type="GhostableInLibrary" />
    <File Path="epj-logo.png" Url="epj-logo.png" Type="GhostableInLibrary" />
  </Module>
</Elements>

您可以编写一个小的C#应用程序来为您创建xml文件,如下所示:

代码语言:javascript
运行
复制
 var info = new DirectoryInfo(@"c:\pathToImageFolder");
        var files = info.GetFiles();

        TextWriter writer = new StreamWriter(@"c:\pathToImageFolder\module.xml");

        writer.WriteLine("<Elements Id=...");
        foreach (FileInfo file in files)
        {
            writer.WriteLine(string.Format("<File Path='{0}' Url='{0}' Type='GhostableInLibrary' />",file.Name));
        }
        writer.WriteLine("</Elements>");
        writer.Flush();
        writer.Close();
票数 4
EN

Stack Overflow用户

发布于 2010-09-15 22:17:30

下面是一个适用于我的快速Powershell函数:

代码语言:javascript
运行
复制
function Enum-FilesInPath
{
    param([string]$path)

    Get-ChildItem -path $path | foreach-object {
        # if a directory, recurse...
        if ($_.PSIsContainer)
        {
            $recursivePath = [string]::Format("{0}\{1}", $path, $_.Name)
            Enum-FilesInPath $recursivePath
        }
        # else if a file, print out the xml for it
        else
        {
            $finalPath = [string]::Format("{0}\{1}", $path, $_.Name)
            $url = $finalPath.Replace("\", "/") # backslashes for path, forward slashes for urls
            [string]::Format("`t<File Url=`"$url`" Path=`"$fullPath`" Type=`"GhostableInLibrary`" />")
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1268126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档