C#
Parameters
- searchPattern
- The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. The default pattern is "*", which returns all files.
- searchOption
- One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is System.IO.SearchOption.TopDirectoryOnly.
Return Value
An enumerable collection of files that matches searchPattern and searchOption.Exception | Description |
---|---|
System.ArgumentNullException | searchPattern is null. |
System.ArgumentOutOfRangeException | searchOption is not a valid System.IO.SearchOption value. |
System.IO.DirectoryNotFoundException | The path encapsulated in the DirectoryInfo object is invalid (for example, it is on an unmapped drive). |
System.Security.SecurityException | The caller does not have the required permission. |
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