Platform Core .NET Assemblies API
GetFiles(String,String,SearchOption) Method
See Also  Send Feedback
Terrasoft.IO Namespace > IDirectory Interface > GetFiles Method : GetFiles(String,String,SearchOption) Method
path
The relative or absolute path to the directory to search. This string is not case-sensitive.
searchPattern
The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but doesn't support regular expressions.
searchOption
One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.

Glossary Item Box

Returns full path names of the files that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.

Syntax

 
C#
 
 

Parameters

path
The relative or absolute path to the directory to search. This string is not case-sensitive.
searchPattern
The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but doesn't support regular expressions.
searchOption
One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.

Return Value

An array of the full-path file names in the specified directory that match the specified search pattern and option or an empty array if no files found.

Exceptions

ExceptionDescription
System.IO.IOException

path is a file name.

-or-

A network error has occurred.

System.UnauthorizedAccessExceptionThe caller does not have the required permission.
System.ArgumentException

path is a zero-length string, contains only white space, or contains one or more invalid characters.

-or-

searchPattern does not contain a valid pattern.

System.ArgumentNullExceptionpath or searchPattern is null.
System.ArgumentOutOfRangeExceptionsearchOption is not a valid System.IO.SearchOption value.
System.IO.DirectoryNotFoundExceptionThe specified path is not found or invalid (for example, it is on an unmapped drive).

Remarks

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 searchPattern string "*t" searches for all names in path ending with the letter "t". The searchPattern string "s*" searches for all names in path beginning with the letter "s". searchPattern cannot end in two periods ("..") or contain two periods ("..") followed by '/' or '\', nor can it contain any invalid characters.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

© Terrasoft 2002-2018.