Views/Home/RecusionIndex.cshtml

@{
  ViewBag.Title = "Recursion Index";
  Layout = "~/Views/Shared/_Layout.cshtml";
}

  <div class="col-sm-12">

    <div class="row col-sm-12 text-center"><h4 style="color:red;">(click on headings for code snippets)</h4></div>

    <div class="row col-sm-12">
      <div class="col-sm-4"></div>
      <div id="dvRecursion" data-toggle="modal" data-target="#modalRecursion" class="row text-center col-sm-4"><h1>Recursion</h1></div>
      <div class="col-sm-4"></div>
    </div>

    <div class="row">
      <div class="col-sm-12" style="border:2px solid fuchsia;">
        <div id="dvImageFiles" data-toggle="modal" data-target="#modal2ndDelegate" class="row text-center"><h2>List of pics in Images Drectory</h2></div>
        @if (ViewBag.ImageFiles != null)
        {
          foreach (var item in ViewBag.ImageFiles)
          {
            <div class="row" style="padding-left:25px;">
              @item
            </div>
          }
        }
        else
        { <dv class="row" style="padding-left:25px;">ViewBag.ImageFiles is null</dv>}
      </div>
    </div>
    <div class="row" style="height:40px;"></div>

    @*Recustion Modal*@
    <div id="modalRecursion" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              ×
            </button>
            <h4 class="modal-title text-center">
              Recursion snippets
            </h4>
          </div>
          <div class="modal-body">
            <form class="form-horizontal" role="form" method="post">
              <div class="form-group" style="font-weight:bold;">
                <pre>
     private void findFiles(string path, IList<string> fileList)
     {
       foreach(string fileName in Directory.GetFiles(path))
       {
         int loc = 0;
         loc = fileName.IndexOf("Images");
         string f = fileName.Substring(loc);
         fileList.Add(f);
       }
                
       foreach(string directory in Directory.GetDirectories(path))
       {
         findFiles(directory, fileList);
       }
          
       ViewBag.ImageFiles = fileList;
     }
</pre>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">
              Close
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>