title: list down the files in a folder in asp.net mvc
body: <p>I want to list all the files in folder once page loading . so </p>
  
  <p>For that I just created like this</p>
  
  <p>HTML code </p>
  
  <pre><code>&lt;input id="idd" type="file" multiple="true" class="file" data-preview-file-type="text"&gt;
  </code></pre>
  
  <p>Script </p>
  
  <pre><code>@section scripts{   
  
   &lt;script type="text/javascript"&gt;    
  
    $(document).ready(function () {
          $.ajax({
              url: '/Home/filesinfolder',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (data) {
                  $.each(data, function (index, val) {
                      $('#idd').append('&lt;li&gt;&lt;a href="http://'+ val.Url +'" target="_new"&gt;' + val.Url + '&lt;/a&gt;&lt;/li&gt;');
                  });
              },
              error: function (xhr, status, err) {
                  console.log('Response code:' + xhr.status);
                  console.log('[Error:' + err + '] ' + status);
              }
          });
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Controller method</p>
  
  <pre><code>    public JsonResult filesinfolder()
      {
          DirectoryInfo salesFTPDirectory = null;
          FileInfo[] files = null;
  
          string salesFTPPath = "C:/filePath";
  
          salesFTPDirectory = new DirectoryInfo(salesFTPPath);
          files = salesFTPDirectory.GetFiles();
  
          files = files.OrderBy(f =&gt; f.Name).ToArray();
  
          var salesFiles = files.Where(f =&gt; f.Extension == ".xls" || f.Extension == ".xml" || f.Extension == ".jps" || f.Extension == ".jpg" || f.Extension == ".jpeg" || f.Extension == ".png");
  
          return Json(salesFiles.ToList());
      }
  </code></pre>
  
  <p>But this is isn't list down anything at all , but once I debug I can see this <code>filesinfolder</code> method calling and finding files in folder.</p>