Geeks With Blogs
Gaurav Taneja Great dreams... never even get out of the box. It takes an uncommon amount of guts to put your dreams on the line, to hold them up and say, "How good or how bad am I?" That's where courage comes in.

using

System;

using

System.Collections.Specialized;

using

System.ComponentModel;

using

System.Data;

using

System.Drawing;

using

System.Web;

using

System.Web.SessionState;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.HtmlControls;

using

System.DirectoryServices;

 

namespace

SearchIIS

{

 

/// <summary>

 

/// Summary description for iissearch.

 

/// </summary>

 

public class iissearch : System.Web.UI.Page

{

 

protected System.Web.UI.WebControls.ListBox lst_iisdir;

 

 

private void Page_Load(object sender, System.EventArgs e)

{

 

// Put user code to initialize the page here

 

if (!Page.IsPostBack)

{

GetIISVirtualDirectories();

 

}

 

}

#region

Web Form Designer generated code

 

override protected void OnInit(EventArgs e)

{

 

//

 

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

 

//

InitializeComponent();

 

base.OnInit(e);

}

 

 

/// <summary>

 

/// Required method for Designer support - do not modify

 

/// the contents of this method with the code editor.

 

/// </summary>

 

private void InitializeComponent()

{

 

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

 

public void GetIISVirtualDirectories()

{

 

string provider = "IIS://192.168.2.250/W3SVC/1/Root"; // Add your Ip Address

DirectoryEntries dirEntries =

null;

DirectoryEntry dirEntry =

null;

 

try

{

dirEntry =

new DirectoryEntry(provider);

dirEntry.RefreshCache();

dirEntries = dirEntry.Children;

 

foreach(DirectoryEntry objDir in dirEntries)

{

Response.Write("IIS Virtual Directories: " + (objDir.Name.ToString()) + "<br>");

}

dirEntry.Dispose();

 

}

catch(Exception Ex)

{

Response.Write(Ex.Message);

}

}

}

}

Posted on Tuesday, April 3, 2007 12:00 PM .Net | Back to top


Comments on this post: Getting IIS Virtual Directories

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Gaurav Taneja | Powered by: GeeksWithBlogs.net