
How to enum DirectoryEntries without foreach in C#??
Hi All,
I can sucessfully loop through a list of DirectoryEntries with:
DirectoryEntry servers = new DirectoryEntry("IIS://x/W3SVC")
foreach(DirectoryEntry de in servers)
{do something}
but not with:
DirectoryEntry servers = new DirectoryEntry("IIS://x/W3SVC")
IEnumerator serverList = servers.Children.GetEnumerator();
serverList.Reset();
DirectoryEntry de = (DirectoryEntry) serverList.Current; ==>XX
This returns a "System.InvalidOperationException: Enumerator is positioned
before the first item or after the last item." in the XX marked line above.
I start with the same object and I am able to get an IEnumerator, but no
entries! I have to handle a large set of objects and wish to abort, if I've
found the right one.
Any hints, tips and thought what's wrong with my code/thinking would be very
welcomed!!!!
Best regards,
Manfred Braun
(Private)
Mannheim
Germany
(Remove the anti-spam-underscore to mail me!)