user259286
user259286

Reputation: 1005

How to delete the virtual directory entry from IIS?

I have written some code to delete Virtual Directories, however all that it is doing is that it deleted the folder structures beneath the Virtuals and not the actual virtual entries in IIS, so that if I open IIS I can still see the listings under Default Web Site.

How does one delete virtual while also deleting the entries so that nothing is listed under Default Web Site?

Upvotes: 1

Views: 3178

Answers (1)

kateroh
kateroh

Reputation: 4406

This should work for both IIS6 (metabase config system) and IIS7 (xml-based config system):

string vDirPath = "IIS://localhost/W3SVC/<siteIndex>/ROOT/<vdirName>";
DirectoryEntry vDir = new DirectoryEntry(vDirPath);
vDir.DeleteTree();

where siteIndex is an index of your site and vdirName is the name of your vdir.

Upvotes: 3

Related Questions