Compartilhar via


File.List Method

Definition

Overloads

List()

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

List(IFilenameFilter)

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

List()

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

[Android.Runtime.Register("list", "()[Ljava/lang/String;", "GetListHandler")]
public virtual string[]? List ();
[<Android.Runtime.Register("list", "()[Ljava/lang/String;", "GetListHandler")>]
abstract member List : unit -> string[]
override this.List : unit -> string[]

Returns

String[]

An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

Attributes

Remarks

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Note that the java.nio.file.Files class defines the java.nio.file.Files#newDirectoryStream(Path) newDirectoryStream method to open a directory and iterate over the names of the files in the directory. This may use less resources when working with very large directories, and may be more responsive when working with remote directories.

Java documentation for java.io.File.list().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

List(IFilenameFilter)

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

[Android.Runtime.Register("list", "(Ljava/io/FilenameFilter;)[Ljava/lang/String;", "GetList_Ljava_io_FilenameFilter_Handler")]
public virtual string[]? List (Java.IO.IFilenameFilter? filter);
[<Android.Runtime.Register("list", "(Ljava/io/FilenameFilter;)[Ljava/lang/String;", "GetList_Ljava_io_FilenameFilter_Handler")>]
abstract member List : Java.IO.IFilenameFilter -> string[]
override this.List : Java.IO.IFilenameFilter -> string[]

Parameters

filter
IFilenameFilter

A filename filter

Returns

String[]

An array of strings naming the files and directories in the directory denoted by this abstract pathname that were accepted by the given filter. The array will be empty if the directory is empty or if no names were accepted by the filter. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

Attributes

Remarks

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the #list() method, except that the strings in the returned array must satisfy the filter. If the given filter is null then all names are accepted. Otherwise, a name satisfies the filter if and only if the value true results when the FilenameFilter#accept FilenameFilter.accept(File,&nbsp;String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.

Java documentation for java.io.File.list(java.io.FilenameFilter).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to