using (DirectoryEntry parent = new DirectoryEntry("IIS://localhost/W3SVC/1/Root"))
{
using (DirectoryEntry newFolder = (DirectoryEntry)parent.Invoke("Create", "IIsWebVirtualDir", "NewVDir"))
{
newFolder.InvokeSet("Path", @"G:\Temp\NewVDir"); // Does not seem to show up in IIS manager without this.
newFolder.Invoke("AppCreate", true);
newFolder.InvokeSet("AppFriendlyName", "NewVDir");
newFolder.CommitChanges();
}
}