BasicProperties BasicProperties BasicProperties BasicProperties BasicProperties Class


Provides access to the basic properties, like the size of the item or the date the item was last modified, of the item (like a file or folder).

public : sealed class BasicProperties : IBasicProperties, IStorageItemExtraProperties
struct winrt::Windows::Storage::FileProperties::BasicProperties : IBasicProperties, IStorageItemExtraProperties
public sealed class BasicProperties : IBasicProperties, IStorageItemExtraProperties
Public NotInheritable Class BasicProperties Implements IBasicProperties, IStorageItemExtraProperties
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


The File access sample demonstrates how to retrieve properties of a file, including basic properties like Size and DateModified.

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

        // Get basic properties
        BasicProperties basicProperties = await file.GetBasicPropertiesAsync();
        outputText.AppendLine("File size: " + basicProperties.Size + " bytes");
        outputText.AppendLine("Date modified: " + basicProperties.DateModified);

        // Specify more properties to retrieve
        readonly string dateAccessedProperty = "System.DateAccessed";
        readonly string fileOwnerProperty = "System.FileOwner";
        List<string> propertiesName = new List<string>();

        // Get the specified properties through StorageFile.Properties
        IDictionary<string, object> extraProperties = await file.Properties.RetrievePropertiesAsync(propertiesName);
        var propValue = extraProperties[dateAccessedProperty];
        if (propValue != null)
            outputText.AppendLine("Date accessed: " + propValue);
        propValue = extraProperties[fileOwnerProperty];
        if (propValue != null)
            outputText.AppendLine("File owner: " + propValue);
// Handle errors with catch blocks
catch (FileNotFoundException)
 // For example, handle a file not found error

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

    // Get top level file properties
    outputDiv.innerHTML = "Filename: " + + "<br/>";
    outputDiv.innerHTML += "File type: " + file.fileType + "<br/>";

    // Get basic properties
    file.getBasicPropertiesAsync().then(function (basicProperties) {
        outputDiv.innerHTML += "Size: " + basicProperties.size + " bytes<br/>";
        outputDiv.innerHTML += "Date modified: " + basicProperties.dateModified + "<br/>";

        // Get extra properties
        return[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 GetBasicPropertiesAsync completes, basicProperties gets a BasicProperties object.

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


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

You can get a BasicProperties object using any of the following methods and properties:


DateModified DateModified DateModified DateModified DateModified

Gets the timestamp of the last time the file was modified.

public : DateTime DateModified { get; }
DateTime DateModified();
public DateTimeOffset DateModified { get; }
Public ReadOnly Property DateModified As DateTimeOffset
var dateTimeOffset = basicProperties.dateModified;
DateTimeOffset DateTimeOffset DateTimeOffset

The timestamp.


If the date property isn't set, this value defaults to 0 which can be translated into misleading dates in different programming languages. In JavaScript, for example, 0 translates to December 16, 1600. You should always check that this property is a real value and not 0.

ItemDate ItemDate ItemDate ItemDate ItemDate

Gets the most relevant date for the item.

public : DateTime ItemDate { get; }
DateTime ItemDate();
public DateTimeOffset ItemDate { get; }
Public ReadOnly Property ItemDate As DateTimeOffset
var dateTimeOffset = basicProperties.itemDate;
DateTimeOffset DateTimeOffset DateTimeOffset

The item's date.

The system determines the most relevant date based on the type of the item. For example, if the item is a photo the date in System.Photo.DateTaken is returned. Or if the item is a song the date in System.Media.DateReleased is returned.


This property lets you get the most relevant date for an item without the need to access item-specific properties.

Size Size Size Size Size

Gets the size of the file in bytes.

public : ulong Size { get; }
ulong Size();
public ulong Size { get; }
Public ReadOnly Property Size As ulong
var ulong = basicProperties.size;
ulong ulong ulong

The size of the file in bytes.


RetrievePropertiesAsync(IIterable) RetrievePropertiesAsync(IIterable) RetrievePropertiesAsync(IIterable) RetrievePropertiesAsync(IIterable) RetrievePropertiesAsync(IIterable)

Retrieves the specified properties associated with the item.

public : IAsyncOperation<IMap<Platform::String, Platform::Object>> RetrievePropertiesAsync(IIterable<Platform::String> propertiesToRetrieve)
IAsyncOperation<IMap<winrt::hstring, winrt::Windows::Foundation::IInspectable>> RetrievePropertiesAsync(IIterable<winrt::hstring> propertiesToRetrieve) const;
public IAsyncOperation<IDictionary<string, object>> RetrievePropertiesAsync(IEnumerable<String> propertiesToRetrieve)
Public Function RetrievePropertiesAsync(propertiesToRetrieve As IEnumerable<String>) As IAsyncOperation<IDictionary<string, object>>( Of IMap )
Windows.Storage.FileProperties.BasicProperties.retrievePropertiesAsync(propertiesToRetrieve).done( /* Your success and error handlers */ );
IEnumerable<String> IEnumerable<String> IEnumerable<String>

A collection that contains the names of the properties to retrieve.

IAsyncOperation<IDictionary<string, object>> IAsyncOperation<IDictionary<string, object>> IAsyncOperation<IDictionary<string, object>>

When this method completes successfully, it returns a collection (type IMap ) that contains the specified properties and values as key-value pairs.


In JavaScript, use then or done to specify handler functions that will capture and process the collection when it is returned.

See Also

SavePropertiesAsync() SavePropertiesAsync() SavePropertiesAsync() SavePropertiesAsync() SavePropertiesAsync()

Saves all properties associated with the item.

public : IAsyncAction SavePropertiesAsync()
IAsyncAction SavePropertiesAsync() const;
public IAsyncAction SavePropertiesAsync()
Public Function SavePropertiesAsync() As IAsyncAction
Windows.Storage.FileProperties.BasicProperties.savePropertiesAsync().done( /* Your success and error handlers */ );

No object or value is returned when this method completes.


If any one of the property values is invalid, none of the values will be saved.

See Also

SavePropertiesAsync(IIterable<>>) SavePropertiesAsync(IIterable<>>) SavePropertiesAsync(IIterable<>>) SavePropertiesAsync(IIterable<>>) SavePropertiesAsync(IIterable<>>)

Saves the specified properties and values associated with the item.

public : IAsyncAction SavePropertiesAsync(IIterable<IKeyValuePair<Platform::String, Platform::Object>> propertiesToSave)
IAsyncAction SavePropertiesAsync(IIterable<IKeyValuePair<winrt::hstring, winrt::Windows::Foundation::IInspectable>> propertiesToSave) const;
public IAsyncAction SavePropertiesAsync(IEnumerable<KeyValuePair<String, Object>> propertiesToSave)
Public Function SavePropertiesAsync(propertiesToSave As IEnumerable<KeyValuePair<String, Object>>) As IAsyncAction
Windows.Storage.FileProperties.BasicProperties.savePropertiesAsync(propertiesToSave).done( /* Your success and error handlers */ );
IEnumerable<KeyValuePair<String, Object>> IEnumerable<KeyValuePair<String, Object>> IEnumerable<KeyValuePair<String, Object>>

A collection that contains the names and values of the properties to save as key-value pairs (type IKeyValuePair ).


No object or value is returned when this method completes.

See Also

See Also