想知道为什么“DeleteAsync”不会删除文件,但“File.Delete”会这样做。谁可以给我解释一下这个?起初我认为文件是打开的,但是如果文件是打开的,“File.Delete”也不应该删除它,或者......?
private static async void FILESYSTEM_RemoveVideoPosterIfExist(string posterFileNameOnStorage)
{
IStorageItem videoPosterIStorageItem = await ApplicationData.Current.LocalFolder.TryGetItemAsync(SYSTEM_UserVideoPosterFolder + @"\" + DATABASE_SelectedUserInformation.UserName + "." + SYSTEM_UserPosterFolderExtension + @"\" + posterFileNameOnStorage);
if (videoPosterIStorageItem != null)
{
try
{
//Why this doesn't delete file...
await videoPosterIStorageItem.DeleteAsync(StorageDeleteOption.PermanentDelete);
}
catch
{
//But this one will delete file.
StorageFolder applicationStorageFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(SYSTEM_UserVideoPosterFolder + @"\" + DATABASE_SelectedUserInformation.UserName + "." + SYSTEM_UserPosterFolderExtension + @"\");
File.Delete(applicationStorageFolder.Path + @"\" + posterFileNameOnStorage);
}
}
}