Creating Virtual Directories with c#

IIS "management" with c#

Posted 15 March 2010 - 12:14 AM

Hey all who Dreamincode.

Been facing a few minor issues when trying to manage IIS with my Windows Application.
I can create sites without any problem but when i wanna point a Virtual Directory to a specific site it stops and sais RPC-Server is unavailable.
Been googling it and found out that its something with authentication security in windows so ive tried to reconfigure a few things to make it work better. However there is still one thing that im scratching my head about.

When i do it with code it becomes an application under the site.
If i do it in IIS - manager it doesnt. And ive tried to find some other help about it on the net but they all have app.create in the code.
Posting code under here:

IIS version: 7 with 6 compability activated.

string pref = Prefix name like abc001 (have a function to make sure that it becomes the right format with 3 alphs and 3 numbers.)
string vPhys = The physical path on the computer where the wanted virtual directory exists.

So my thoughts here was.. Can i, with code, create a Virtual Directory or does it need to be an application under the site?
I havent worked much with IIS combo and c# and since i only find application creates on the net im a little confused.
Am i missing something really easy? :s

//Claus

*edit note*
Im working on the code as i wait so it will be updated. Trying to write the updates here.
Found one small issue.. Forgot to specify the site ID under new DirectoryEntry. Fixed. But still it creates an application.
oDC aint used anywhere, forgot to comment it away when posted.