Windows.Storage.FileProperties.ImageProperties

December 9, 2020 ยท View on GitHub

-description

Provides access to the image-related properties of an item (like a file or folder).

-remarks

You can access a ImageProperties object asynchronously using the getImagePropertiesAsync method from the Properties property of an item (like a file of folder), or synchronously using the ImageProperties property if it is available. You can get a ImageProperties object using any of the following methods and properties:

Note

Properties that are get or set using a property handler that is defined by another app (like Microsoft Word) may not be accessible. Instead, you can try to get these properties using a file query that is backed by the system index. For more information, see QueryOptions.

For more code samples about accessing properties, see the File access sample.

-examples

This example demonstrates how to retrieve properties of a file, including image properties like DateTaken and Rating.


try
{
    StorageFile file = rootPage.sampleFile;
    if (file != null)
    {
        StringBuilder outputText = new StringBuilder();

        // Get image properties
        ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
        outputText.AppendLine("Date taken: " + imageProperties.DateTaken);
        outputText.AppendLine("Rating: " + imageProperties.Rating);
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
 // For example, handle a file not found error
}

After GetImagePropertiesAsync completes, imageProperties gets a ImageProperties object.

In the example, file contains a StorageFile that represents the file to retrieve properties for.

-see-also

StorageItemContentProperties.getImagePropertiesAsync method, Windows.Storage.BulkAccess.FileInformation.imageProperties property, Windows.Storage.BulkAccess.FolderInformation.imageProperties property, Windows.Storage.BulkAccess.IStorageItemInformation.ImageProperties property