I am sending months (get the value from File path) and File path to the MVC view so I can show a List of the month that is linked to the File to download it like this:
OCT(that is linked to file path)
Nov (that is linked to file path)
December (that is linked to file path)
This is my Controller C# code:
public ActionResult Help()
{
var releaseNoteFiles = Directory.GetFiles(Server.MapPath("~/Content/ReleaseNotes"));
List<string> month = new List<string>();
foreach (var releaseNoteFile in releaseNoteFiles)
{
month.Add(new Regex("([^A-Z]*)([a-zA-Z]*)").Match(Path.GetFileNameWithoutExtension(releaseNoteFile).Split('.').Last()).Groups[2].Value);
}
ViewBag.releaseNoteFilesmonth = month; /Has October,Nov,...
ViewBag.releaseNoteFiles = releaseNoteFiles; /Has Path to the File
return View();
}
This is my view that I have a problem with how to send 2 lists (Filename and Path) This code shows the list 2 times.
@foreach (var item in ViewBag.releaseNoteFilesmonth)
{foreach (var item2 in ViewBag.releaseNoteFiles)
{
@item <a href="@item2">@item</a>
<br />
}
}