Click here to Skip to main content
15,886,919 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 294.2K   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

 
GeneralRe: ApplicationProtection Property. Pin
Member 145133319-Oct-04 5:02
Member 145133319-Oct-04 5:02 
QuestionHow to implement in ASP.NET? Pin
PhoneTech23-Feb-03 6:43
PhoneTech23-Feb-03 6:43 
AnswerRe: How to implement in ASP.NET? Pin
Daron Yndem13-Jul-04 0:13
Daron Yndem13-Jul-04 0:13 
AnswerSolution for ASP.NET! Pin
Sire40417-Oct-04 23:20
Sire40417-Oct-04 23:20 
QuestionHow do you delete Virtual Directory? Pin
ahaddad20-Feb-03 8:18
ahaddad20-Feb-03 8:18 
AnswerRe: How do you delete Virtual Directory? Pin
Anonymous24-Jul-03 3:39
Anonymous24-Jul-03 3:39 
GeneralRe: How do you delete Virtual Directory? Pin
Anonymous18-Nov-04 22:55
Anonymous18-Nov-04 22:55 
AnswerRe: How do you delete Virtual Directory? Pin
kalph12-Dec-05 22:13
kalph12-Dec-05 22:13 
AnswerRe: How do you delete Virtual Directory? Pin
kalph12-Dec-05 22:17
kalph12-Dec-05 22:17 
AnswerRe: How do you delete Virtual Directory? Pin
Member 314043814-Jan-08 0:58
Member 314043814-Jan-08 0:58 
AnswerRe: How do you delete Virtual Directory? Pin
Member 314043814-Jan-08 1:00
Member 314043814-Jan-08 1:00 
GeneralI solved this problem. Pin
kind51114-May-02 22:16
kind51114-May-02 22:16 
GeneralRe: I solved this problem. Pin
Orion Buttigieg17-May-02 6:29
Orion Buttigieg17-May-02 6:29 
GeneralRe: I solved this problem. Pin
kind5119-Jun-02 16:46
kind5119-Jun-02 16:46 
GeneralRe: I solved this problem. Pin
Orion Buttigieg10-Jun-02 4:47
Orion Buttigieg10-Jun-02 4:47 
GeneralRe: I solved this problem. Pin
kwik220-Mar-06 0:37
kwik220-Mar-06 0:37 
GeneralPath not set Pin
Kannan Kalyanaraman17-Mar-02 2:32
Kannan Kalyanaraman17-Mar-02 2:32 
GeneralI Have the same problem Pin
SMORGS26-Feb-03 12:17
SMORGS26-Feb-03 12:17 
GeneralRe: I Have the same problem Pin
Anonymous18-Mar-04 17:03
Anonymous18-Mar-04 17:03 
GeneralRe: I Have the same problem Pin
hackaroy28-Apr-04 13:11
hackaroy28-Apr-04 13:11 

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.