title: How to load images to page from image folder dynamically
body: <p>I'm using MVC4 c#.  I'm trying to load images that I need to show on a page dynamically by reading the content of the image folder and doing a foreach loop.  I'm not sure how to read the content of the folder which is called ImageFiles which is located in the project and not the c:\ of the server.  This is what I used and it works on my local computer but when I use <code>../../filename/filename/ImageFiles</code> as the path it does not work.  Can anyone help?</p>
  
  <pre><code>string filePath = @"../../Content/EventFiles/ImageFiles";
  DirectoryInfo directory = new DirectoryInfo(filePath);
  
  @foreach (FileInfo file in directory.GetFiles())
  {
      &lt;\a href="../../Content/EventFiles/ImageFiles/@file.Name"&gt;
         &lt;\img src="/Content/EventFiles/ImageFiles/@file.Name" /&gt;
      &lt;\/a&gt;
  }
  </code></pre>