asp.net-mvc 将文件夹中的所有文件包含在一个包中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19894275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Include all files in a folder in a single bundle
提问by Jordan Axe
When using BundleConfigis it possible to include all files of a folder including all the files of the childfolders (and their childfolders etc.)?
使用时BundleConfig是否可以包含文件夹的所有文件,包括子文件夹(及其子文件夹等)的所有文件?
I found .IncludeDirectory()but it seems to only include the files of the folder itself, not the files of the subfolders.
我发现.IncludeDirectory()但它似乎只包括文件夹本身的文件,而不包括子文件夹的文件。
回答by Zabavsky
Use the overload of IncludeDirectorymethod which accepts bool searchSubdirectoriesas third parameter.
使用接受作为第三个参数的IncludeDirectory方法的重载bool searchSubdirectories。
MSDN:
微软:
searchSubdirectories - Specifies whether to recursively search subdirectories of directoryVirtualPath.
searchSubdirectories - 指定是否递归搜索 directoryVirtualPath 的子目录。
Example:
例子:
bundles.Add(new ScriptBundle("~/bundles/scripts")
.IncludeDirectory("~/Scripts", "*.js", true));

