title: Web API returning list of files from folder via JSON
body: <p>I am trying to get a list of the jpg files in a particular folder, and return that list via json to an angular bootstrap carousel.  The angular bootstrap part works fine if I hard code the list of files in json format and manually put that on the scope, but I can not figure out how return the data in the proper format from this web api controller.  The problem is mainly with the foreach loop I believe.  I've tried various methods with the @ symbol, double quotes, single quotes, etc. I am definitely stuck at this point.  Thank you.</p>
  
  <pre><code>[Route("api/GetIncidentPhotos/{Id}/Incidents")]
  public IEnumerable&lt;string&gt; GetIncidentPhotos(int Id)
  { 
      List&lt;string&gt; files = new List&lt;string&gt;();
      DirectoryInfo dirInfo = new DirectoryInfo(@"C:\SecurityManager\Photos\3\");
  
      foreach (FileInfo fInfo in dirInfo.GetFiles())
      {
          files.Add("{ 'path:' + '\\Photos\\3\\' + fInfo.Name + '}' ");            
      }
  
      return files.ToList();
  
  }
  </code></pre>
  
  <p>Here is the html/bootstrap/angular markup that uses the list of files returned from the API call to build the image carousel.</p>
  
  <pre><code>&lt;div class="carousel-inner"&gt;
      &lt;div class="item" ng-class="{active:!$index}" ng-repeat="photo in photoPath"&gt;            
          &lt;img src="{{ photo.path }}" class="img-responsive" style="border: solid 1px;"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>