private static async Task InitDefaultDownloadFolder() { var futureAccessList = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList; if (!(await DefaultDownloadFolderExists())) { bool created = false; int i = 1; do { try { var myfolder = await DownloadsFolder.CreateFolderAsync((i == 1)? "Received" : $"Received ({i})"); FutureAccessListHelper.MakeSureFutureAccessListIsNotFull(); futureAccessList.AddOrReplace(_downloadMainFolder, myfolder); created = true; } catch { i++; } }while (!created); } }
private static async Task <IStorageFolder> TrySetDownloadFolder(IStorageFolder folder) { var futureAccessList = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList; FutureAccessListHelper.MakeSureFutureAccessListIsNotFull(); futureAccessList.AddOrReplace(_downloadMainFolder, folder); return(await GetDefaultDownloadFolder()); //Make sure everything's fine }