Retrieves an array of strongly typed System.IO.FileSystemInfo objects representing the files and subdirectories that match the specified search criteria.
An array of strongly typed FileSystemInfo objects matching the search criteria.
searchPattern can be a combination of literal and wildcard characters, but doesn't support regular expressions. The following wildcard specifiers are permitted in searchPattern.
* (asterisk) |
Zero or more characters in that position. |
? (question mark) |
Zero or one character in that position. |
Characters other than the wildcard are literal characters. For example, the string "*t" searches for all names in ending with the letter "t". ". The searchPattern string "s*" searches for all names in path beginning with the letter "s".
This method is not recursive.
For subdirectories, the System.IO.FileSystemInfo objects returned by this method can be cast to the derived class System.IO.DirectoryInfo. Use the System.IO.FileAttributes value returned by the FileSystemInfo.Attributes property to determine whether the System.IO.FileSystemInfo represents a file or a directory.
Wild cards are permitted. For example, the searchPattern string "*t" searches for all directory names in path ending with the letter "t". The searchPattern string "s*" searches for all directory names in path beginning with the letter "s".
The string ".." can only be used in searchPattern if it is specified as a part of a valid directory name, such as in the directory name "a..b". It cannot be used to move up the directory hierarchy. If there are no files or directories, or no files or directories that match the searchPattern string in the System.IO.DirectoryInfo, this method returns an empty array.
This method pre-populates the values of the following System.IO.FileSystemInfo properties: