public async Task ChangeVideoCacheFolder() { // フォルダを取得 var folderPicker = new Windows.Storage.Pickers.FolderPicker(); folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads; folderPicker.FileTypeFilter.Add("*"); var newFolder = await folderPicker.PickSingleFolderAsync(); if (newFolder == null) { return; } await _messenger.Send <Events.StartCacheSaveFolderChangingAsyncRequestMessage>(); try { // 現在進行中のキャッシュ情報を取得 // 全てのキャッシュ更新を一時停止 var resumeInfo = await _videoCacheManager.PauseAllDownloadOperationAsync(); // 新しいフォルダに存在するキャッシュ済みファイルを取り込む await ImportCacheRequestFromNewFolderItems(newFolder); // フォルダのアイテムの移動を開始 var oldFolder = _videoCacheManager.VideoCacheFolder; await MoveFolderItemsToDestination(oldFolder, newFolder); // VideoCacheManagerのフォルダ指定を変更 _videoCacheManager.VideoCacheFolder = newFolder; // 停止したキャッシュを再開 foreach (var resume in resumeInfo.PausedVideoIdList) { await _videoCacheManager.PushCacheRequestAsync(resume, NicoVideoQuality.Unknown); } // 新しい指定フォルダをFutureAccessListへ登録 StorageApplicationPermissions.FutureAccessList.AddOrReplace(CACHE_FOLDER_NAME, newFolder); } catch (Exception e) { _logger.ZLogError(e, e.Message); } finally { _messenger.Send <Events.EndCacheSaveFolderChangingMessage>(); } }