?
Solved

Get list of virtual directories and locations?

Posted on 2007-07-19
3
Medium Priority
?
250 Views
Last Modified: 2013-11-07
How do I get the list of virtual directories and their locations on my computer programatically in .net?
0
Comment
Question by:kayhustle
1 Comment
 
LVL 8

Accepted Solution

by:
sabeesh earned 2000 total points
ID: 19527719
This would be helpful

http://www.dotnetjunkies.com/WebLog/razor/archive/2004/12/15/37118.aspx

private DirectoryEntry iisServer;

public DirectoryEntries GetVirtualDirectories()

{

try

{

string serverName = "localhost";

string VirDirSchemaName = "IIsWebVirtualDir";

iisServer = new DirectoryEntry("IIS://" + serverName + "/W3SVC/1");

DirectoryEntry folderRoot = iisServer.Children.Find("Root",VirDirSchemaName);


return folderRoot.Children;

}

catch (Exception e)

{

throw new Exception("Error while retrieving virtual directories.",e);

}

}

When you get the DirectoryEntries object back from the GetVirtualDirectories() method you can go through the collection with a normal foreach.

DirectoryEntries entries = GetVirtualDirectories();

foreach(DirectoryEntry d in entries)

{

listBox1.Items.Add(d.Name + "(" + d.Path + ")");

}

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question