GetFiles Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Returns the names of files (including their paths) in the specified directory.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

public static string[] GetFiles(
	string path
)

Parameters

path
Type: System..::..String
The directory from which to retrieve the files.

Return Value

Type: array<System..::..String>[]()[][]
An array of the full names (including paths) for the files in the specified directory.

The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

The returned file names are appended to the supplied path parameter.

If there are no files, this method returns an empty array.

This method is identical to GetFiles with the asterisk (*) specified as the search pattern.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.

The order of the returned file names is not guaranteed; use the Sort()()()() method if a specific sort order is required.

The path parameter is not case-sensitive.

For a list of common I/O tasks, see Common I/O Tasks.

Show: