protected void Page_Load(object sender, EventArgs e) { string htmlSiteBar = string.Empty; string ulFormat = "<ul>{0}</ul>"; string liFormat = "<li>{0}</li>"; string aFormat = "<a href='{0}'>{1}</a>"; foreach (string file in Directory.GetFiles(Server.MapPath("~"), "*.aspx", SearchOption.AllDirectories)) { string url = Page.ResolveClientUrl("~/" + SubRoot(file).Replace("\\", "/")); htmlSiteBar += (string.Format(liFormat, string.Format(aFormat, url, SubRoot(file).Replace(".aspx", string.Empty).Replace("\\", "/")))); } htmlSiteBar = string.Format(ulFormat, htmlSiteBar); txtPages.Text = htmlSiteBar; } string SubRoot(string fullPath) { return fullPath.Replace(Server.MapPath("~"), string.Empty); }