Combine just adds a subdirectory to a root path, and adds a / if there is not one already:
/// <summary>
/// Join a parent path and a child path in a metabase.
/// </summary>
/// <param name="parent">Parent path</param>
/// <param name="child">Child node</param>
/// <returns></returns>
public static String Combine(String parent, String child) {
string SEP = @"\";
// trim off any separator on the child
if (child.StartsWith(SEP)) {
child=child.Substring(1);
}
if (parent.EndsWith(SEP)) {
return parent + child;
} else {
return parent + SEP + child;
}
}
You could replace it with
dirEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/Root/" + dir);
Ensure also that the number of the web server is '1' - that is the Default Web Site (I took this example out of code where it is configurable).
Craig