包括文件夹中的所有文件在一个单一的包 [英] Include all files in a folder in a single bundle

查看:103
本文介绍了包括文件夹中的所有文件在一个单一的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 BundleConfig 是否有可能包括一个文件夹中的所有文件,包括childfolders中的所有文件(及其childfolders等)?

When using BundleConfig is it possible to include all files of a folder including all the files of the childfolders (and their childfolders etc.)?

我发现 .IncludeDirectory(),但它似乎只包括文件夹本身的文件,子文件夹而不是文件。

I found .IncludeDirectory() but it seems to only include the files of the folder itself, not the files of the subfolders.

推荐答案

使用的 IncludeDirectory 方法,它接受布尔searchSubdirectories 作为第三个参数。

Use the overload of IncludeDirectory method which accepts bool searchSubdirectories as third parameter.

MSDN:

searchSubdirectories - 指定是否递归搜索
  directoryVirtualPath的子目录。

searchSubdirectories - Specifies whether to recursively search subdirectories of directoryVirtualPath.

例如:

bundles.Add(new ScriptBundle("~/bundles/scripts")
    .IncludeDirectory("~/Scripts", "*.js", true));

这篇关于包括文件夹中的所有文件在一个单一的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆