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


C# IStorageFile.DeleteAsync方法代码示例

本文整理汇总了C#中IStorageFile.DeleteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageFile.DeleteAsync方法的具体用法?C# IStorageFile.DeleteAsync怎么用?C# IStorageFile.DeleteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStorageFile的用法示例。


在下文中一共展示了IStorageFile.DeleteAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: MoveAndReplaceAsync

        /// <summary>
        /// Moves the current file to the location of the specified file and replaces the specified file in that location.
        /// </summary>
        /// <param name="fileToReplace">The file to replace.</param>
        /// <returns>No object or value is returned by this method.</returns>
        public Task MoveAndReplaceAsync(IStorageFile fileToReplace)
        {
            if(fileToReplace == null)
            {
                throw new ArgumentNullException("fileToReplace");
            }
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            return _file.MoveAndReplaceAsync((Windows.Storage.StorageFile)((StorageFile)fileToReplace)).AsTask();
#elif __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN
            return Task.Run(async () =>
            {
                string fileName = fileToReplace.Name;
                string folder = global::System.IO.Path.GetDirectoryName(fileToReplace.Path);
                await fileToReplace.DeleteAsync();
                await MoveAsync(await StorageFolder.GetFolderFromPathAsync(folder), fileName);
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
开发者ID:inthehand,项目名称:Charming,代码行数:25,代码来源:StorageFile.cs


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