Errr, some catchy title.... RSS 2.0
 Friday, November 09, 2007

This is a quick tip. Below is the code that you can use when you want to find what's the name of the Virtual Directory.

string virtualDirectory =AppDomain.CurrentDomain.FriendlyName;

virtualDirectory = virtualDirectory.Substring(virtualDirectory.LastIndexOf("/"));

virtualDirectory = virtualDirectory.Substring(0, virtualDirectory.IndexOf("-"));

 

Notes: This has been tested in IIS 6. If you run this code in ASP.NET Dev Server you'll get an exception as CurrentDomain.FrienlyName will not contain any '/' (no virtual directory).

Friday, November 09, 2007 2:35:53 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
ASP.NET
Comments are closed.
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Marcin Waligora
Sign In
All Content © 2008, Marcin Waligora
DasBlog theme 'Business' created by Christoph De Baene (delarou)