public static async Task <ObservableCollection <StorageFile> > GetitemsAsyncNotIndexed(string Token) { //ItemList.Dispose(); StorageFolder inputFloder = null; ObservableCollection <StorageFile> StorageFilelist = new ObservableCollection <StorageFile>(); try { inputFloder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(Token); // var inputFlies=await inputFloder.GetFilesAsync(); } catch (System.ArgumentException) { Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Remove(Token); FaTokenDataAccess.DeleteData(Token); MruTokenDataAccess.DeleteData(Token); if (inputFloder != null) { StorageFilelist = await Retrieve_(inputFloder, StorageFilelist); } return(StorageFilelist); } if (inputFloder != null) { StorageFilelist = await Retrieve_(inputFloder, StorageFilelist); } return(StorageFilelist); }
public static async Task <string> GetAccessPermissions() { bool Folderflag = false; var folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop; folderPicker.FileTypeFilter.Add("*"); System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now; StorageFolder folder = await folderPicker.PickSingleFolderAsync(); foreach (var data in FaTokenDataAccess.GetData()) { if (data.Folder == folder.Path) { Folderflag = true; break; } } if (folder != null && !Folderflag) { // Add to MRU with metadata (For example, a string that represents the date) MruToken = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(folder, currentTime.ToShortDateString()); // Add to FA without metadata FaToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(folder, currentTime.ToShortDateString()); } else { return("Operation cancelled."); } return(folder.Path); }
/// <summary> /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行, /// 已执行,逻辑上等同于 main() 或 WinMain()。 /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; FaTokenDataAccess.InitializefaTokenDatabase(); MruTokenDataAccess.InitializemruTokenDatabase(); UnhandledException += OnUnhandledExceptionAsync; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledExceptionAsync; }
private void Button_Click_1(object sender, RoutedEventArgs e) { ItemAccess.SettingChanged = true; ItemAccess.End_sort = true; foreach (var token in selectedtokens) { FaTokenDataAccess.DeleteData(token); } ItemAccess.Cache.Clear(); ItemAccess.Cache_flag = false; itemsource = new List <string>(); foreach (var data in FaTokenDataAccess.GetData()) { itemsource.Add(data.Folder); } Output.ItemsSource = itemsource; }
public FileAdd_Page() { this.InitializeComponent(); //Background myBrush = GetBGColor(); myPivot.Background = myBrush; Button_add.Background = myBrush; Delete.Background = myBrush; Confirm.Background = myBrush; //Switch MaxNum.PlaceholderText = UserSettings.GetMaxNumber().ToString(); Language.PlaceholderText = ApplicationLanguages.PrimaryLanguageOverride; combo.PlaceholderText = GetBGColor().Color.ToString(); try { if (localSettings.Values["ToggleSwitch_Menu"].ToString() == "Open") { Toggle_Menu.IsOn = true; } else { Toggle_Menu.IsOn = false; } } catch (System.NullReferenceException) { Toggle_Menu.IsOn = true; localSettings.Values["ToggleSwitch_Menu"] = "Open"; } //Binding Data itemsource = new List <string>(); foreach (var data in FaTokenDataAccess.GetData()) { itemsource.Add(data.Folder); } Output.ItemsSource = itemsource; }
//保存许可路径 private async void Button_add_Click(object sender, RoutedEventArgs e) { ItemAccess.SettingChanged = true; Database data_in = new Database(); var Floder_in = await GetUserPermissions.GetAccessPermissions(); if (Floder_in == "Operation cancelled.") { return; } else { try { ItemAccess.End_sort = true; ItemAccess.Cache_flag = false; ItemAccess.Cache.Clear(); data_in.Folder = Floder_in; data_in.Token = GetUserPermissions.FaToken; FaTokenDataAccess.AddData(data_in); // mruTokenDataAccess.AddData(GetUserPermissions.mruToken); itemsource = new List <string>(); foreach (var data in FaTokenDataAccess.GetData()) { itemsource.Add(data.Folder); } Output.ItemsSource = itemsource; } catch (IOException File_E) { Debug.WriteLine(File_E); return; } } }