TargetFileRequestDeferral class

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

Syntax


public sealed class TargetFileRequestDeferral

Attributes

[Version(0x06020000)]

Members

The TargetFileRequestDeferral class has these types of members:

Methods

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

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

 

Remarks

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.

Examples

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



// Event handler
private async void OnTargetFileRequested(FileSavePickerUI sender, TargetFileRequestedEventArgs e)
{
    // Respond to TargetFileRequested event on the background thread on which it was raised

    // Requesting a deferral allows the app to call another asynchronous method and complete the request at a later time
    var deferral = e.Request.GetDeferral();

    // Create file and assign to TargetFile property
    e.Request.TargetFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(sender.FileName, CreationCollisionOption.GenerateUniqueName);

    // Complete the deferral to let the Picker know the request is finished
    deferral.Complete();
}

// Register for the event
fileSavePickerUI.TargetFileRequested += new TypedEventHandler<FileSavePickerUI, TargetFileRequestedEventArgs>(OnTargetFileRequested);

In the example, e contains a TargetFileRequestedEventArgs object.

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

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]

Namespace

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

Metadata

Windows.winmd

See also

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

 

 

Show:
© 2015 Microsoft