本文整理汇总了C#中IStorageFile.GetBasicPropertiesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageFile.GetBasicPropertiesAsync方法的具体用法?C# IStorageFile.GetBasicPropertiesAsync怎么用?C# IStorageFile.GetBasicPropertiesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorageFile
的用法示例。
在下文中一共展示了IStorageFile.GetBasicPropertiesAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCreateEntryFromFile
private static async Task<ZipArchiveEntry> DoCreateEntryFromFile(ZipArchive destination, IStorageFile sourceFile, string entryName, CompressionLevel? compressionLevel)
{
if (destination == null)
throw new ArgumentNullException("destination");
if (sourceFile == null)
throw new ArgumentNullException("sourceFile");
if (entryName == null)
throw new ArgumentNullException("entryName");
using (Stream stream = (await sourceFile.OpenReadAsync()).AsStream())
{
ZipArchiveEntry zipArchiveEntry = compressionLevel.HasValue ? destination.CreateEntry(entryName, compressionLevel.Value) : destination.CreateEntry(entryName);
var props = await sourceFile.GetBasicPropertiesAsync();
DateTime dateTime = props.DateModified.UtcDateTime;
if (dateTime.Year < 1980 || dateTime.Year > 2107)
dateTime = new DateTime(1980, 1, 1, 0, 0, 0);
zipArchiveEntry.LastWriteTime = (DateTimeOffset)dateTime;
using (Stream destination1 = zipArchiveEntry.Open())
{
await stream.CopyToAsync(destination1);
}
return zipArchiveEntry;
}
}
示例2: UpdateBoundSize
private async void UpdateBoundSize(IStorageFile _backingFile)
{
var props = await _backingFile.GetBasicPropertiesAsync();
FileSize = GetHumanReadableSize(props.Size);
}
示例3: CreateAttachmentObject
private static async Task<EmailMessage> CreateAttachmentObject(IStorageFile attachmentTempFile, Unity.Core.AttachmentData attachment, EmailMessage mail)
{
await (FileIO.WriteBytesAsync(attachmentTempFile, attachment.Data).AsTask());
var properties = await attachmentTempFile.GetBasicPropertiesAsync();
if (properties.Size < (ulong)(attachment.DataSize))
{
mail.Attachments.Add(new EmailAttachment(attachment.FileName, RandomAccessStreamReference.CreateFromFile(attachmentTempFile)));
}
return mail;
}
示例4: GetSizeAsync
/// <summary>
/// Gets a file's size.
/// </summary>
private async Task<long> GetSizeAsync(IStorageFile file)
{
BasicProperties fileProperties = await file.GetBasicPropertiesAsync().AsTask().ConfigureAwait(false);
return (long)fileProperties.Size;
}