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
}

GetImagePropertiesAsyncimageProperties 완료되면 ImageProperties 개체를 가져옵니다. 또한 RetrievePropertiesAsyncextraProperties 완료되면 지정된 속성이 포함된 개체를 가져옵니다.

이 예제 file 에서는 속성을 검색할 파일을 나타내는 StorageFile 을 포함합니다.

설명

참고

다른 앱(예: Microsoft Word)에서 정의한 속성 처리기를 사용하여 가져오기 또는 설정된 속성에 액세스할 수 없습니다. 대신 시스템 인덱스에서 백업하는 파일 쿼리를 사용하여 이러한 속성을 가져올 수 있습니다. 자세한 내용은 QueryOptions를 참조하세요.

속성에 액세스하는 방법에 대한 자세한 코드 샘플은 파일 액세스 샘플을 참조하세요.

적용 대상