TargetFileRequestDeferral class

TargetFileRequestDeferral class

Used by an app that provides a save location to indicate asynchronously that the app is finished responding to a targetfilerequested event.


var targetFileRequestDeferral = targetFileRequest.getDeferral();


The TargetFileRequestDeferral class has these types of members:


The TargetFileRequestDeferral class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

Complete Signals that the app providing the save location finished responding to a targetfilerequested event.



If your app participates in the File Save Picker contract and a targetfilerequested event fires, your app should create a new storageFile that represents the file the user wants to save. The name of the storageFile you create must match the name of the file specified by the fileName property. The storageFile you create is returned to the app that called the file picker (the calling app) so that the calling app can write content to the file. Learn more about responding to this event in targetFileRequestedEventArgs.

Your app, as the provider of a save location, can signal that it has finished its asynchronous response to a targetfilerequested event by calling targetFileRequestDeferral.complete. Learn more about responding asynchronously to a targetfilerequested event in targetFileRequestedEventArgs.


The File picker sample demonstrates how to respond to a targetfilerequested event handler, including how to get a deferral.

// Event handler
function onTargetFileRequested(e) {
    var deferral;
    deferral = e.request.getDeferral();

    // Create a file to pass to the file picker which then gives it to the calling app
    Windows.Storage.ApplicationData.current.localFolder.createFileAsync(fileSavePickerUI.fileName).done(function (file) {
            // Assign the resulting file to the targetFile property and complete the deferral to indicate success
        e.request.targetFile = file;
    }, function () {
        // Set the targetFile property to null and complete the deferral to indicate failure
        e.request.targetFile = null;

// Register for the event
fileSavePickerUI.addEventListener("targetfilerequested", onTargetFileRequested, false);

In the example, e contains a TargetFileRequestedEventArgs object.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0 [for Xbox, see UWP features that aren't yet supported on Xbox]

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Storage::Pickers::Provider [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


Windows::Storage::Pickers::Provider [C++]





See also

FileSavePickerUI.TargetFileRequested event
TargetFileRequest class
TargetFileRequestDeferral class
TargetFileRequestDeferral.Complete method
TargetFileRequestedEventArgs class
Windows.Storage.StorageFile class



© 2016 Microsoft