Najam Sikander Awan

covering web stack along with microsoft technologies

How to Get Directory Name of the Page Currently Displaying

| Comments

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

1
2
3
4
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

Comments