C# DirectoryInfo GetFileSystemInfos()

Description

DirectoryInfo GetFileSystemInfos() Returns an array of strongly typed FileSystemInfo entries representing all the files and subdirectories in a directory.

Syntax

DirectoryInfo.GetFileSystemInfos() has the following syntax.


public FileSystemInfo[] GetFileSystemInfos()

Returns

DirectoryInfo.GetFileSystemInfos() method returns

Example

The following example counts the files and directories under the specified directory.


using System;/* w ww . ja  v a 2 s . c  o m*/
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        DirectoryInfo di = new DirectoryInfo(@"C:\Users\");
        foreach (var fi in di.GetFileSystemInfos())
        {
            Console.WriteLine(fi.Name);
        }

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter