Pergunta

How can I programmatically (vb.net or C#) create a Virtual Directory in the Root of website in IIS7?

Using this link, it only shows you how to make one inside an application but I need it at the ROOT level of the website.

Foi útil?

Solução

This worked on my machine (notice the indexes in second line):

ServerManager iisManager = new ServerManager();
Application app = iisManager.Sites[0].Applications[0];
app.VirtualDirectories.Add("/VDir", "d:\\MyVDir");
iisManager.Update(); 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top