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 = 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).
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.