Share via


GetFiles Method

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

Returns a file list from the current directory.

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

Syntax

'Declaration
Public Function GetFiles As FileInfo()
public FileInfo[] GetFiles()
public:
array<FileInfo^>^ GetFiles()
member GetFiles : unit -> FileInfo[] 
public function GetFiles() : FileInfo[]

Return Value

Type: array<System.IO. . :: . .FileInfo> [] () [] []
An array of type FileInfo.

Remarks

The EnumerateFiles and GetFiles methods differ as follows:

  • When you use EnumerateFiles, you can start enumerating the collection of FileInfo objects before the whole collection is returned.

  • When you use GetFiles, you must wait for the whole array of FileInfo objects to be returned before you can access the array.

Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

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

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

.NET Framework Security

See Also

Reference

DirectoryInfo Class

System.IO Namespace