Asp.net implements IIS control management (creating and managing Web virtual directories)

Source: Internet
Author: User
(1) CreateWebDir. cs example
String sServer = "localhost ";
String VirtualDir = "Bug2004"; virtual directory
String PathDir = @ "D: myWebDirTestBug2000" physical Directory
IISManager iisMg = new IISManager (sServer );
IisMg. Connect ();
If (iisMg. Exists (VirtualDir])
{
Console. Write (VirtualDir + "is exist! ");
}
Else
{
MyINI. IniWriteValue ("WebDir", "WebDirExist", "false ");
IisMg. get_AnonymousUser ();
String [] anonymousUser = new string [2];
AnonymousUser [0] = iisMg. AnonymousUserName;
AnonymousUser [1] = iisMg. AnonymousUserPass;
VirtualDirectory newVirDir = new VirtualDirectory (VirtualDir, PathDir, anonymousUser );
If (iisMg. Create (newVirDir ))
Console. Write (VirtualDir + "created successfully! ");
Else
Console. Write (VirtualDir + "creation failed! ");
}
IisMg. Close ();
(2) CreateWebDir. cs *************************************** ********************
Using System;
Using System. Data;
Using System. DirectoryServices;
Using System. Collections;
Namespace CreateWebDir
{
/// <Summary>
/// Summary of IISManager.
/// </Summary>
Public class IISManager
{
// Define
Private string _ server, _ website, _ AnonymousUserPass, _ AnonymousUserName;
Private VirtualDirectories _ virdirs;
Protected System. DirectoryServices. DirectoryEntry rootfolder;
Private bool _ batchflag;
Public IISManager ()
{
// By default, localhost is used to access the local machine.
_ Server = "localhost ";
_ Website = "1 ";
_ Batchflag = false;
}
Public IISManager (string strServer)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.