HTML and CSS Reference
In-Depth Information
FIGURE 9-6
Getting the name of the selected file.
You don't need to take any special care to get the name of a file or its file type. Three properties
are available:
name, displayName,
and
fileType.
. If you need to read some additional file properties
(such as, size or date), then you need a call to
getBasicPropertiesAsync
, as shown below:
savePicker.pickSaveFileAsync().then(function (file) {
if (file) {
file.getBasicPropertiesAsync().then(function (basicProperties) {
TodoList.alert(file.name + "(" + basicProperties.size + " bytes)");
});
}
});
File properties are split in three groups: built-in, basic, and extended. Built-in properties are name
and file type, and they are retrieved along with the file content. Basic properties include
size
and
dateModified;
; basic properties must be retrieved via a call to
getBasicPropertiesAsync
. Extra properties
must be accessed via a preliminary call to
retrievePropertiesAsync
. Here's an example:
file
.properties
.retrievePropertiesAsync([fileOwnerProperty, dateAccessedProperty])
.done(function (extraProperties) {
TodoList.alert(extraProperties[dateAccessedProperty]);
}
Typical properties you retrieve in this way are
fileOwner
and
dateAccessed.
Search WWH ::
Custom Search