当前位置: 首页>>代码示例>>C#>>正文


C# IStorageFile.CopyAsync方法代码示例

本文整理汇总了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;
        }
开发者ID:jimgrant,项目名称:ProgrammingWindowsStoreApps,代码行数:30,代码来源:ReportItem.cs

示例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;
		}
开发者ID:lolluslollus,项目名称:UniFiler10,代码行数:44,代码来源:FolderVM.cs


注:本文中的IStorageFile.CopyAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。