StorageItemContentProperties class

Applies to Windows and Windows Phone

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

Syntax


var storageItemContentProperties = storageFile.properties;

Attributes

[Version(0x06020000)]

Members

The StorageItemContentProperties class has these types of members:

Methods

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

MethodDescription
GetDocumentPropertiesAsync Retrieves the document properties of the item (like a file of folder).
GetImagePropertiesAsync Retrieves the image properties of the item (like a file of folder).
GetMusicPropertiesAsync Retrieves the music properties of the item (like a file of folder).
GetVideoPropertiesAsync Retrieves the video properties of the item (like a file of folder).
RetrievePropertiesAsync Retrieves the specified properties associated with the item.
SavePropertiesAsync() Saves all properties associated with the item.
SavePropertiesAsync(IIterable(IKeyValuePair)) Saves the specified properties and values associated with the item.

 

Remarks

You can get a StorageItemContentProperties object using the Properties property that is available on the following objects:

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 content properties or specified properties from a file using StorageFile.Properties.



var file = SdkSample.sampleFile;
if (file !== null) {
    var outputDiv = document.getElementById("output");

    // Get image properties
    file.properties.getImagePropertiesAsync().then(function (imageProperties) {
        outputDiv.innerHTML += "Date taken: " + imageProperties.dateTaken + "<br />";
        outputDiv.innerHTML += "Rating: " + imageProperties.rating + "<br />";

        // Specify more properties to retrieve
        var dateAccessedProperty = "System.DateAccessed";
        var fileOwnerProperty    = "System.FileOwner";

        // Get the specified properties through storageFile.properties
        return file.properties.retrievePropertiesAsync([fileOwnerProperty, dateAccessedProperty]);
    }).done(function (extraProperties) {
        var propValue = extraProperties[dateAccessedProperty];
        if (propValue !== null) {
            outputDiv.innerHTML += "Date accessed: " + propValue + "<br />";
        }
        propValue = extraProperties[fileOwnerProperty];
        if (propValue !== null) {
            outputDiv.innerHTML += "File owner: " + propValue;
        }
    },
    // Handle errors with an error function
	   function (error) {
	       // Handle errors encountered while retrieving properties
    });
}

After GetImagePropertiesAsync completes, imageProperties gets a ImageProperties object. Additionally, after RetrievePropertiesAsync completes, extraProperties gets an object that contains the specified properties.

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

Requirements

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.FileProperties
Windows::Storage::FileProperties [C++]

Metadata

Windows.winmd

See also

Windows.Storage.StorageFile.properties property
Windows.Storage.StorageFolder.properties property
Windows.Storage.BulkAccess.fileInformation.properties property
Windows.Storage.BulkAccess.folderInformation.properties property

 

 

Show:
© 2014 Microsoft