Question

Given virtual directory and port can you find the actual path of a web application? I can get the virtual directory and port via a visual studio setup project, and I'd like to make some modification to the web.config file after install (using a custom action).

Was it helpful?

Solution

You could use DirectoryEntry class:

using (var entry = new DirectoryEntry("IIS://server/W3SVC/1/root/VirtualDirectoryName"))
{
    var physicalPath = entry.Properties["Path"].Value;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top