本文整理汇总了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;
}
示例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
}