Windows.Storage.StorageFile
December 9, 2020 ยท View on GitHub
-description
Represents a file. Provides information about the file and its content, and ways to manipulate them.
-remarks
Typically, you access StorageFile objects as the result of asynchronous method and/or function calls. For example, both of the static methods GetFileFromPathAsync and GetFileFromApplicationUriAsync return a StorageFile that represents the specified file.
Additionally, whenever you call a file picker to let the user pick a file (or files) the file picker will return the file as a StorageFile.
Note
StorageFile objects can't represent files that are ".lnk", ".url", or ".wsh" file types.
Version history
| Windows version | SDK version | Value added |
|---|---|---|
| 2004 | 19041 | GetFileFromPathForUserAsync |
-examples
This example shows you how to call a file picker, using FileOpenPicker.PickSingleFileAsync to capture and process a file that the users picks.
var openPicker = new FileOpenPicker();
StorageFile file = await openPicker.PickSingleFileAsync();
// Process picked file
if (file != null)
{
// Store file for future access
Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);
}
else
{
// The user didn't pick a file
}
After PickSingleFileAsync completes, file gets the picked file as a StorageFile.
In the example, openPicker contains a FileOpenPicker object. To learn more about using file picker see Open files and folders with a picker.
Additionally, fileToken gets an identifier that you can use to retrieve the file from the FutureAccessList. To learn more about storing files and folders so you can access them again later, see FutureAccessList, MostRecentlyUsedList and Track recently used files and folders.
-see-also
StorageFolder, IStorageFile, IStorageItem, IRandomAccessStreamReference, IInputStreamReference, IStorageItemProperties, IStorageItemProperties2, IStorageItem2, IStorageItemPropertiesWithProvider, IStorageFilePropertiesWithAvailability, Serializing and deserializing data sample, File access sample
-capabilities
documentsLibrary, musicLibrary, picturesLibrary, videosLibrary