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
2009-09-09 15:19:01
This is good stuff, but I get "The RPC server is unavailable." when I execute it.
Irwin
2009-09-09 17:39:18
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
2009-09-09 18:31:08
ok, i was using incorrect syntax for the path. thanks
Irwin
2009-09-14 15:53:03