StorageFolder.GetFilesAsync() | getFilesAsync() method

Gets the files in the current folder.

Syntax


storageFolder.getFilesAsync().done( /* Your success and error handlers */ );

Parameters

This method has no parameters.

Return value

Type: IAsyncOperation<IVectorView>

When this method completes successfully, it returns a list of the files in the current folder. The list is of type IReadOnlyList<StorageFile>. Each file in the list is represented by a StorageFile object.

Exceptions

ExceptionCondition
System.UnauthorizedAccessException

You don't have permission to access the contents of the current folder.

Remarks

This query is a shallow query that returns only files in the current folder. For a list of methods that identifies shallow queries and deep queries, see the Remarks in the topic GetFilesAsync.

To specify additional query options, call the CreateFileQueryWithOptions method.

To get items that are files or folders, call the GetItemsAsync method.

Examples

The following example shows how to get the files in the current folder by calling the GetFilesAsync() method.


// Get the app's installation folder.
var appFolder =
    Windows.ApplicationModel.Package.current.installedLocation;

// Get the files in the current folder.
var filesInFolderPromise = appFolder.getFilesAsync();
filesInFolderPromise.done(function getFilesSuccess(filesInFolder) {

    // Iterate over the results and print the list of files
    // to the Visual Studio Output window.
    filesInFolder.forEach(function forEachFile(file) {
        console.log(file.name, file.dateCreated);
    });
});

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

See also

StorageFolder
GetFilesAsync(CommonFileQuery, UInt32, UInt32)
GetFilesAsync(CommonFileQuery)
GetItemsAsync

 

 

Show:
© 2015 Microsoft