我可以使用以下代码在应用程序中创建虚拟目录:
ServerManager iisManager = new ServerManager();
Application app = iisManager.Sites["NewSite"].Applications["/Sales"];
app.VirtualDirectories.Add("/VDir", "d:\\MyVDir");
iisManager.CommitChanges();
但我无法在网站的根目录中创建虚拟目录。
¿任何想法?
答案 0 :(得分:4)
答案是这样的:
ServerManager iisManager = new ServerManager();
Site mySite = iisManager.Sites["nameOfYourSite"];
mySite.Applications[0].VirtualDirectories.Add("/nameVirtualDirectory","VirtualDirectoryPath");
iisManager.CommitChanges();