Include all files in a folder in a single bundle

asp.net MvcVisual Studioasp.net Mvc-4

asp.net Mvc Problem Overview


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

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

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

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

MSDN:

> searchSubdirectories - Specifies whether to recursively search > subdirectories of directoryVirtualPath.

Example:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJordan AxeView Question on Stackoverflow
Solution 1 - asp.net MvcZabavskyView Answer on Stackoverflow