public ActionResult Directories()
{
GetFolderInfo folder = new GetFolderInfo();
{
string dir = @"C:\";
foreach (string d in Directory.GetDirectories(dir))
{
List<string> ab = new List<string>();
ab.Add(Path.GetFileName(d));
folder.FolderInformation = ab.ToString();
}
}
return View(folder);
}
Ok so in my views, i call this but i do not get correct list. I want this method to show me all the file names in the folder 'dir' and display it in my test website
@model TestMVC.Models.GetFolderInfo
@{
ViewBag.Title = "Directories";
}
<h2>Directories</h2>
<table>
<tr>
<td>
@Model.FolderInformation
</td>
</tr>
</table>
this above is my views for the method and my model is
namespace TestMVC.Models
{
public class GetFolderInfo
{
public string FolderInformation { get; set; }
}
}