Click here to Skip to main content
15,867,330 members
Articles / Programming Languages / Visual Basic
Article

How to create a virtual directory with C#

Rate me:
Please Sign up or sign in to vote.
4.30/5 (24 votes)
5 Jul 2001 293.5K   6.4K   59   45
A simple example of using the DirectoryServices namespace in .NET

Sample Image - virtualdir.jpg

Introduction

This "how to" is only one more sample of how to use the DirectoryServices namespace in the Microsoft.Net framework. This sample uses IIS as its Active Directory provider. The access to Active Directory in .Net is so easy. You use System.DirectoryServices.dll for simple access.

I implemented a simple class called IISManager, it has two methods: Connect and CreateVirtualDirectory.

// To use it...
            
// Default constructor initialize the servername to localhost
// you could use IISManager(servername) 
IISManager isMang = new IISManager();
isMang.Connect();
try
{
	isMang.CreateVirtualDirectory(txtName.Text,txtPath.Text);
}
catch (Exception ex)
{
	MessageBox.Show(ex.Message);
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Uruguay Uruguay
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionDoes not work properly with Windows 7 64 bit and VS 2010 Pin
JVH35-Oct-11 5:33
JVH35-Oct-11 5:33 
AnswerRe: Does not work properly with Windows 7 64 bit and VS 2010 Pin
fjdiewornncalwe24-Jan-12 4:35
professionalfjdiewornncalwe24-Jan-12 4:35 
GeneralUnable to create virtual directory in a remote machine using directory entry class Pin
santhoshkumars@zsl.com13-Oct-09 3:02
santhoshkumars@zsl.com13-Oct-09 3:02 
GeneralSharing folder via internet... Pin
b0074-Nov-08 10:49
b0074-Nov-08 10:49 
Questionhow to access the files of public folder of a remote machine in vb.net window application Pin
kk_upadhyay27-Feb-08 20:16
kk_upadhyay27-Feb-08 20:16 
GeneralExample systray app to create/edit virtual directories Pin
YetAnotherDeveloper27-Nov-07 17:08
YetAnotherDeveloper27-Nov-07 17:08 
GeneralModified CreateVirtualDirectory method to allow running ASP.Net App's Pin
Vahid_N24-Jun-07 20:48
Vahid_N24-Jun-07 20:48 
QuestionHow to Turn Off Anonymous Authentication Pin
Tom So12-Jan-07 8:41
Tom So12-Jan-07 8:41 
GeneralUnknown name exception while creating Virtual Directory on remote machine Pin
kdp_1236-Dec-06 17:45
kdp_1236-Dec-06 17:45 
GeneralRe: Unknown name exception while creating Virtual Directory on remote machine Pin
pavankumarchakilam1-Apr-10 21:03
pavankumarchakilam1-Apr-10 21:03 
GeneralNot works with Add method Pin
Yuri Kiselev22-Nov-06 0:00
Yuri Kiselev22-Nov-06 0:00 
GeneralRe: Not works with Add method Pin
WIROL18-Oct-07 0:04
WIROL18-Oct-07 0:04 
GeneralAnother way of creation and deletion of VD in 2.0 Pin
digitally_urs17-Nov-06 2:35
digitally_urs17-Nov-06 2:35 
GeneralIIS Virtual Directory Pin
Sen K Mathew17-Jul-05 20:12
Sen K Mathew17-Jul-05 20:12 
GeneralRe: IIS Virtual Directory Pin
avidgator18-Aug-05 15:01
avidgator18-Aug-05 15:01 
QuestionHow do I create VD pointing to another site Pin
Kushal Prasad29-Mar-05 20:38
Kushal Prasad29-Mar-05 20:38 
GeneralI found this version Pin
alan_every18-Dec-03 3:10
alan_every18-Dec-03 3:10 
GeneralI am unable to set a path in the real path Pin
vimalkd19-Oct-03 5:11
vimalkd19-Oct-03 5:11 
Hi well whenever I am running this program I am having a problem that it is unaable to find the path. So can anyone help me with how to define the real path of the virtual directory

GeneralRe: I am unable to set a path in the real path Pin
cuongnle6-Aug-07 22:28
cuongnle6-Aug-07 22:28 
GeneralRe: I am unable to set a path in the real path Pin
WIROL18-Oct-07 0:09
WIROL18-Oct-07 0:09 
GeneralVirtual Directory not showing in Internet Services Manager Pin
SeattleCoder23-Jun-03 11:04
SeattleCoder23-Jun-03 11:04 
GeneralRe: Virtual Directory not showing in Internet Services Manager Pin
Anonymous28-Jun-05 0:45
Anonymous28-Jun-05 0:45 
QuestionHow to Create a VD in non-Default web Site Pin
jshi21-Jun-03 8:51
jshi21-Jun-03 8:51 
AnswerRe: How to Create a VD in non-Default web Site Pin
PhoneTech10-Jul-03 6:22
PhoneTech10-Jul-03 6:22 
GeneralApplicationProtection Property. Pin
Kent Moyle28-May-03 17:49
Kent Moyle28-May-03 17:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.