views:

96

answers:

1

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).

A: 

You could use DirectoryEntry class:

using (var entry = new DirectoryEntry("IIS://server/W3SVC/1/root/VirtualDirectoryName"))
{
    var physicalPath = entry.Properties["Path"].Value;
}
Darin Dimitrov
This is good stuff, but I get "The RPC server is unavailable." when I execute it.
Irwin
Is there a firewall on the server that might be blocking incoming WMI connections? Check this http://msdn.microsoft.com/en-us/library/aa822854(VS.85).aspx
Darin Dimitrov
ok, i was using incorrect syntax for the path. thanks
Irwin