本文整理汇总了C#中IStorageFile.CopyAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageFile.CopyAsync方法的具体用法?C# IStorageFile.CopyAsync怎么用?C# IStorageFile.CopyAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorageFile
的用法示例。
在下文中一共展示了IStorageFile.CopyAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateReportItemAsync
internal static async Task<ReportItem> CreateReportItemAsync(string title, string description,
IMappablePoint point, IStorageFile image)
{
var item = new ReportItem()
{
Title = title,
Description = description,
NativeId = Guid.NewGuid().ToString(),
Status = ReportItemStatus.New
};
item.SetLocation(point);
// save...
var conn = StreetFooRuntime.GetUserDatabase();
await conn.InsertAsync(item);
// stage the image...
if (image != null)
{
// new path...
var manager = new ReportImageCacheManager();
var folder = await manager.GetCacheFolderAsync();
// create...
await image.CopyAsync(folder, item.NativeId + ".jpg");
}
// return...
return item;
}
示例2: ContinueAfterFilePickAsync
private async Task ContinueAfterFilePickAsync(IStorageFile file, IStorageFolder directory, Folder folder, Wallet parentWallet, bool deleteFile = false)
{
bool isImported = false;
try
{
if (directory != null && file != null && await file.GetFileSizeAsync().ConfigureAwait(false) <= ConstantData.MAX_IMPORTABLE_MEDIA_FILE_SIZE)
{
_animationStarter.StartAnimation(AnimationStarter.Animations.Updating);
StorageFile newFile = await file.CopyAsync(directory, file.Name, NameCollisionOption.GenerateUniqueName).AsTask().ConfigureAwait(false);
if (parentWallet == null)
{
isImported = await folder.ImportMediaFileIntoNewWalletAsync(newFile).ConfigureAwait(false);
}
else
{
isImported = await parentWallet.ImportFileAsync(newFile).ConfigureAwait(false);
}
if (!isImported)
{
// delete the copied file if something went wrong
if (newFile != null) await newFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask().ConfigureAwait(false);
Logger.Add_TPL("isImported = false", Logger.AppEventsLogFilename, Logger.Severity.Info);
}
// delete the original file if it was a photo taken with CameraCaptureUI
if (deleteFile) await file.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask().ConfigureAwait(false);
}
}
catch (Exception ex)
{
await Logger.AddAsync(ex.ToString(), Logger.AppEventsLogFilename).ConfigureAwait(false);
}
_animationStarter.EndAllAnimations();
_animationStarter.StartAnimation(isImported
? AnimationStarter.Animations.Success
: AnimationStarter.Animations.Failure);
IsImportingMedia = false;
}