If you want to know only the directory name not the full path of the page that is currently displaying you can use this code
string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
string sRet = oInfo.Directory.Name.ToString();
Response.Write(“<br><br>Directory name===” + sRet + “<br><br>”);
Happy Coding
Najam Sikander Awan



Sunny said,
November 10, 2009 @ 6:34 am
Hi Najam,
This is really great…and very simple 4 line code to get the directory name from the URL….