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).
Syntax
var basicProperties = fileInformation.basicProperties;
Attributes
- MarshalingBehaviorAttribute(Agile)
- MuseAttribute()
- VersionAttribute(NTDDI_WIN8)
Members
The BasicProperties class has these types of members:
Methods
The BasicProperties class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| 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 BasicProperties class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets the timestamp of the last time the file was modified. | |
| Read-only | Gets the most relevant date for the item. | |
| Read-only | Gets the size of the file. |
Remarks
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:
- storageFile.getBasicPropertiesAsync method
- storageFolder.getBasicPropertiesAsync method
- FileInformation.basicProperties property
- FolderInformation.basicProperties property
Examples
The File access sample demonstrates how to retrieve properties of a file, including basic properties like Size and DateModified.
var file = SdkSample.sampleFile; if (file !== null) { var outputDiv = document.getElementById("output"); // Get top level file properties outputDiv.innerHTML = "Filename: " + file.name + "<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 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 GetBasicPropertiesAsync completes, basicProperties gets a BasicProperties object.
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 |
|
Namespace |
|
|
Metadata |
|
See also
- IStorageItemExtraProperties
- Windows.Storage.StorageFile.getBasicPropertiesAsync method
- Windows.Storage.StorageFolder.getBasicPropertiesAsync method
- Windows.Storage.IStorageItem.GetBasicPropertiesAsync method
- Windows.Storage.BulkAccess.FileInformation.basicProperties property
- Windows.Storage.BulkAccess.FolderInformation.BasicProperties property
- Windows.Storage.BulkAccess.IStorageItemInformation.BasicProperties property
Build date: 2/25/2013
