C#
Parameters
- path
- The path to search.
- searchPattern
- The search string to match against the names of subdirectories in path. This parameter can contain a combination of valid literal and wildcard characters, but doesn't support regular expressions.
- searchOption
- One of the SearchOption values that specifies whether the search operation should include all subdirectories or only the current directory.
Return Value
An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.Exception | Description |
---|---|
System.UnauthorizedAccessException | The 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.ArgumentNullException | path or searchPattern
is null . |
System.ArgumentOutOfRangeException | searchOption is not a valid System.IO.SearchOption value. |
System.IO.IOException | path is a file name. |
System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
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.
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