I'm able to create a Virtual Directory in IIS7 using the Microsoft.Web.Administration dll pretty easily in the code shown below but I've been pulling my hair out trying to find out how to give "Network Service" write permissions to the Virtual Directory once it's been created. Can anyone point me in the right direction?
Private Sub CreateVirDir(ByVal WebSite As String, ByVal AppPath As String, ByVal VirPath As String, ByVal DirPath As String)
Dim sm As New Microsoft.Web.Administration.ServerManager()
Dim cpapp As Microsoft.Web.Administration.Application = sm.Sites(WebSite).Applications(AppPath)
cpapp.VirtualDirectories.Add(VirPath, DirPath)
sm.CommitChanges()
End Sub