using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace BreadCrumb
{
[Guid("2717b54c-cefb-466e-aef9-e2de91a9ee2f")]
public class BreadCrumb : System.Web.UI.WebControls.WebParts.WebPart
{
public BreadCrumb()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
Label Label1 = new Label();
string currentFolder = "";
string strTmp = "";
string strLink = "";
if (Page.Request.QueryString["RootFolder"] != null)
{
string[] a;
currentFolder = Page.Request.QueryString["RootFolder"];
currentFolder = currentFolder.Replace("%2f", "/");
currentFolder = currentFolder.Replace("%20", " ");
a = currentFolder.Split('/');
for (int i = (a.Length - 1); i >= 0; i--)
{
if (strTmp.Length > 0)
strTmp = " > " + strTmp;
if (i != (a.Length - 1))
{
//Iteratively gets the link for each folder.
for (int x = 1; x <= i; x++)
{
strLink = strLink + a[x];
if (x != i)
strLink = strLink + "/";
strLink = strLink.Replace("/", "%2f");
strLink = strLink.Replace(" ", "%20");
}
strTmp = "" + a[i] + "" + strTmp;
}
else
strTmp = a[i] + strTmp;
//Reset Link to ""
strLink = "";
if (i == 2) break;
}
}
Label1.Text = "
" + strTmp + "
";this.Controls.Add(Label1);
// TODO: add custom rendering code here.
// Label label = new Label();
// label.Text = "Hello World";
// this.Controls.Add(label);
}
}
}