Lets an app that provides a save location specify the storageFile that represents the file to save and get a deferral so the app can respond asynchronously to a targetFileRequested event.
Syntax
var targetFileRequest = targetFileRequestedEventArgs.request;
Attributes
- VersionAttribute(NTDDI_WIN8)
Members
The TargetFileRequest class has these types of members:
Methods
The TargetFileRequest class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| GetDeferral | Gets a targetFileRequestDeferral that the app providing the save location can use to respond asynchronously to a targetfilerequested event. |
Properties
The TargetFileRequest class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets or sets the IStorageFile object that is provided to represent the file to save by the app that is providing the save location . |
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.
Examples
The File picker sample demonstrates how to respond to a targetfilerequested event handler, including how to use the Request property to get the TargetFileRequest.
// 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; deferral.complete(); }, function () { // Set the targetFile property to null and complete the deferral to indicate failure e.request.targetFile = null; deferral.complete(); }); }; // Register for the event fileSavePickerUI.addEventListener("targetfilerequested", onTargetFileRequested, false);
In the example, e contains a TargetFileRequestedEventArgs object.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
- FileSavePickerUI.TargetFileRequested event
- TargetFileRequest class
- TargetFileRequest.TargetFile property
- TargetFileRequest.GetDeferral method
- TargetFileRequestDeferral class
- TargetFileRequestDeferral.Complete method
- TargetFileRequestedEventArgs class
- TargetFileRequestedEventArgs.Request property
- Windows.Storage.StorageFile class
Build date: 12/4/2012