Not sure if this is still relevant, but itβs rather difficult to find the answers to them yourself. Since I'm just struggling with the answer to this exact question, the best I came up with is that to access the Microsoft.Web.Administration.Site virtual directories, you get access to the first application:
var serverManager = new ServerManager(); site = serverManager.Sites.Add(websiteName, physicalPath, port); var dirs = site.Applications[0].VirtualDirectories;
bit intuitive, but it looks like IIS will create a default application for the website you are adding.
Ales potocnik hahonina
source share