0 out of 1 rated this helpful - Rate this topic

DocumentProperties class

Applies to Windows and Windows Phone

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

Syntax


var documentProperties = fileInformation.documentProperties;

Attributes

[Version(0x06020000)]

Members

The DocumentProperties class has these types of members:

Methods

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

MethodDescription
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.

 

Properties

The DocumentProperties class has these properties.

PropertyAccess typeDescription

Author

Read-onlyGets the name of the document author.

Comment

Read/writeGets or sets the comments associated with the document.

Keywords

Read-onlyGets the collection of keywords associated with the document.

Title

Read/writeGets or sets the title of the document.

 

Remarks

You can access a DocumentProperties object asynchronously using the GetDocumentPropertiesAsync method from the Properties property of an item (like a file of folder), or synchronously using the DocumentProperties property if it is available.

You can get a DocumentProperties 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 use a file query that is backed by the system index to retrieve document properties like Title.



// Create index backed file query and get results
var documentsLibrary = Windows.Storage.KnownFolders.documentsLibrary;
var fileTypeFilter = [".docx"];
var queryOptions = new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.orderByName, fileTypeFilter);
queryOptions.indexerOption = Windows.Storage.Search.IndexerOption.onlyUseIndexer;
var fileQuery = documentsLibrary.createFileQueryWithOptions(queryOptions);
fileQuery.getFilesAsync().then(function (files) {
    // Process resulting files
    if (files.size === 0) {
        // Perform tasks to handle no files found
    } else {
        // Access properties for each file
        files.forEach(function (file) {
            // Get document properties
            file.properties.getDocumentPropertiesAsync().done(function (documentProperties) {
                // Perform tasks with document properties
                var title = documentProperties.title;
            });
        });
    }
},
// Handle errors with an error function
function (error) {
    // Handle errors encountered while processing files
});

While the example uses the DocumentsLibrary to create the query, you can create a query like this for any folder you have access to that you can get as a StorageFolder.

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

StorageItemContentProperties.getDocumentPropertiesAsync method
Windows.Storage.BulkAccess.FileInformation.documentProperties property
Windows.Storage.BulkAccess.FolderInformation.documentProperties property
Windows.Storage.BulkAccess.IStorageItemInformation.DocumentProperties property

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.