How to create an IIS Virtual Directory with C#
The joys of .NET continue! Creating a virtual directory as part of an automated process was never much fun in the past. We used to do it alot to automate the of setup demos and we (referring to Chris K 'cus he shared my pain) used to resort to using .vbs scripts and .bat files... well .... no more... I just had to add a vdir thru automation and did it with .NET... way sooooo easy!
Let me share the joy with you...
//Create a virtual directory
System.EnterpriseServices.Internal.IISVirtualRoot vr = new System.EnterpriseServices.Internal.IISVirtualRoot();
string sError;
vr.Create("IIS://localhost/W3SVC/1/Root",@"C:\Demos\WebServices\","WebServices",out sError);