Search code examples
c#.netwinformsienumerator

How can I count the number of elements in IEnumerator?


I am getting all files in a directory by following code.

IEnumerator FILES = Directory.GetFiles(
                DIRECTORY_PATH).GetEnumerator();

How can I get the total number of files? There's no FILES.Count();


Solution

  • Directory.GetFiles(@"C:\yourdir").Length
    

    will give you count directly