C# Directory GetFileSystemEntries(String, String)

Description

Directory GetFileSystemEntries(String, String) Returns an array of file system entries that match the specified search criteria.

Syntax

Directory.GetFileSystemEntries(String, String) has the following syntax.


public static string[] GetFileSystemEntries(
  string path,
  string searchPattern
)

Parameters

Directory.GetFileSystemEntries(String, String) has the following parameters.

  • path - The path to be searched.
  • searchPattern - The search string to match against the names of files in path. The searchPattern parameter cannot end in two periods ("..") or contain two periods ("..") followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any of the characters in InvalidPathChars.

Returns

Directory.GetFileSystemEntries(String, String) method returns

Example


using System;//w w w  .  j  av  a2 s  .c  o  m

class Class1 
{
    static void Main(string[] args) 
    {
        string[] directoryEntries = System.IO.Directory.GetFileSystemEntries(".","*a"); 

        foreach (string str in directoryEntries) 
        {
            System.Console.WriteLine(str);
        }
    }
}

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