Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace <YOUR_NAMESPACE>
- {
- public class DocumentModel
- {
- public string Name { get; set; }
- public string Data { get; set; }
- }
- public class DocumentationsController : Controller
- {
- // GET: Documentations
- public ActionResult Index()
- {
- var docs = new List<DocumentModel>();
- foreach(var file in System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "/Docs", "*.md"))
- {
- var data = System.IO.File.ReadAllText(file);
- var lines = data.Split('\n');
- docs.Add(new DocumentModel
- {
- Name = (lines.Length > 0 && lines[0].StartsWith("#")) ? lines[0].TrimStart('#') : file.Split('/').Last(),
- Data = data
- });
- }
- ViewBag.docs = docs;
- return View();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement