StorageItemContentProperties Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan akses ke properti terkait konten item (seperti file atau folder).
public ref class StorageItemContentProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class StorageItemContentProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class StorageItemContentProperties
Public NotInheritable Class StorageItemContentProperties
- Warisan
- Atribut
- Penerapan
Persyaratan Windows
Rangkaian perangkat |
Windows 10 (diperkenalkan dalam 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
|
Contoh
Contoh ini menunjukkan cara mengambil properti konten atau properti tertentu dari file menggunakan 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
}
Setelah GetImagePropertiesAsync selesai, imageProperties mendapatkan objek ImageProperties . Selain itu, setelah RetrievePropertiesAsync selesai, extraProperties mendapatkan objek yang berisi properti yang ditentukan (daftar properti yang didukung dapat ditemukan di halaman Properti inti).
Dalam contoh, file berisi StorageFile yang mewakili file yang akan diambil propertinya.
Keterangan
Anda bisa mendapatkan objek StorageItemContentProperties menggunakan properti Properti yang tersedia pada objek berikut:
- Properti StorageFile.Properties
- Properti StorageFolder.Properties
- Properti FileInformation.Properties
- Properti FolderInformation.Properties
Catatan
Properti yang didapatkan atau diatur menggunakan handler properti yang ditentukan oleh aplikasi lain (seperti Microsoft Word) mungkin tidak dapat diakses. Sebagai gantinya, Anda bisa mencoba mendapatkan properti ini menggunakan kueri file yang didukung oleh indeks sistem. Untuk informasi selengkapnya, lihat QueryOptions.
Untuk sampel kode selengkapnya tentang mengakses properti, lihat Sampel akses file.
Metode
GetDocumentPropertiesAsync() |
Mengambil properti dokumen item (seperti file folder). |
GetImagePropertiesAsync() |
Mengambil properti gambar item (seperti file folder). |
GetMusicPropertiesAsync() |
Mengambil properti musik item (seperti file folder). |
GetVideoPropertiesAsync() |
Mengambil properti video item (seperti file folder). |
RetrievePropertiesAsync(IIterable<String>) |
Mengambil properti yang ditentukan yang terkait dengan item. |
SavePropertiesAsync() |
Menyimpan semua properti yang terkait dengan item. |
SavePropertiesAsync(IIterable<KeyValuePair<String,Object>>) |
Menyimpan properti dan nilai yang ditentukan yang terkait dengan item. |