How can I change a virtual directory's physical path in IIS7 and C#?

Posted by Nick on Stack Overflow See other posts from Stack Overflow or by Nick
Published on 2010-03-30T22:40:58Z Indexed on 2010/03/30 22:43 UTC
Read the original article Hit count: 578

Filed under:
|
|

I need to change the where a virtual directory's physical path is in C#.

This is what I have so far:

 using (DirectoryEntry webSiteRoot = WmiUtility.GetWebSiteRootDirectory(webSite))
            {
                DirectoryEntry virtualDirectory =
                    WmiUtility.GetVirtualDirectoryByName(webSiteRoot, vDirName);

                string currentPath = virtualDirectory.Path;


                    virtualDirectory.Path = "C:\somepath"
                    srvMgr.CommitChanges();

It would appear that the VirtualDirectory.Path is not a physical one. Any help?

© Stack Overflow or respective owner

Related posts about iis7

Related posts about c#