title: asp.net mvc dropdownlist with directory files list
body: <p>I want to show all files from a folder "newsletter" with category list. but when I use following code, I got error, my code is :</p>
  
  <pre><code>public ActionResult templatelist()
          {
              var data = _session.emailForcampaigns.Select(m =&gt; m.category).Distinct().AsQueryable(); 
              ViewBag.ddlCategory = new SelectList(data, "category", "category");
              return View(Directory.EnumerateFiles(Server.MapPath("~/newsletter")));
          }
  </code></pre>
  
  <p>and i have following lines in view</p>
  
  <pre><code>&lt;table class="tables" &gt;
      &lt;tr&gt;
          &lt;td&gt;Fiels&lt;/td&gt;
          &lt;td&gt;
              &lt;select id="template" name="template"&gt;
              @foreach (var fullPath in Model)
              {
                  var fileName = Path.GetFileName(fullPath);
                  &lt;option value="@fileName"&gt; @fileName&lt;/option&gt;
              }
              &lt;/select&gt;
          &lt;/td&gt;
       &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td&gt;Category &lt;/td&gt;
          &lt;td&gt;
               @Html.DropDownList("ddlCategory", null, new { @class = "dropdown " })
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>but i am getting error</p>
  
  <p><img src="https://i.stack.imgur.com/ampC1.jpg" alt="enter image description here"></p>