StorageFile.Properties Свойство

Определение

Возвращает объект , предоставляющий доступ к свойствам файла, связанным с содержимым.

public:
 property StorageItemContentProperties ^ Properties { StorageItemContentProperties ^ get(); };
StorageItemContentProperties Properties();
public StorageItemContentProperties Properties { get; }
var storageItemContentProperties = storageFile.properties;
Public ReadOnly Property Properties As StorageItemContentProperties

Значение свойства

Объект , предоставляющий доступ к свойствам файла, связанным с содержимым.

Реализации

Примеры

В этом примере показано, как получить свойства содержимого или указанные свойства из файла с помощью StorageFile.Properties.

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

           // Get image properties
              ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
              outputText.AppendLine("Date taken: " + imageProperties.DateTaken);
              outputText.AppendLine("Rating: " + imageProperties.Rating);

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

        // 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
}

После завершения imagePropertiesgetImagePropertiesAsync получает объект ImageProperties. Кроме того, после завершения RetrievePropertiesAsync получает объект , extraProperties содержащий указанные свойства.

В этом примере содержит файл StorageFile, представляющий файл, file для которого требуется извлечь свойства.

Комментарии

Примечание

Свойства, которые получаются или задаются с помощью обработчика свойств, определенного другим приложением (например, Microsoft Word), могут быть недоступны. Вместо этого можно попытаться получить эти свойства с помощью запроса файла, который поддерживается системным индексом. Дополнительные сведения см. в разделе QueryOptions.

Дополнительные примеры кода о доступе к свойствам см. в разделе Пример доступа к файлам.

Применяется к