private async void btn_CustomDoanPath_Click(object sender, RoutedEventArgs e) { FolderPicker fp = new FolderPicker(); fp.FileTypeFilter.Add(".mp4"); var f = await fp.PickSingleFolderAsync(); if (f == null) { return; } string mruToken = StorageApplicationPermissions.MostRecentlyUsedList.Add(f, f.Path); SettingHelper.Set_DownPath(f.Path); txt_CustomDownPath.Text = f.Path; //读取文件夹 // string mruFirstToken = StorageApplicationPermissions.MostRecentlyUsedList.Entries.First(x=>x.Metadata==f.Path).Token; //StorageFolder retrievedFile = await StorageApplicationPermissions.MostRecentlyUsedList.GetFolderAsync(mruFirstToken); //messShow.Show(mruToken, 3000); }
public async void BrowseFolderWithHiddenPokemon() { FolderPicker folderPicker = new FolderPicker() { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; folderPicker.FileTypeFilter.Add(".txt"); IStorageFolder hpf = await folderPicker.PickSingleFolderAsync(); if (hpf == null) { if (String.IsNullOrEmpty(hiddenPath)) { showErrorDialog("You have to choose folders with blank pokemon pictures. "); } return; } hiddenPath = hpf.Path; OnPropertyChanged("HiddenPath"); }
public async void BrowseFolderWithShownPokemon() { FolderPicker folderPicker = new FolderPicker() { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; folderPicker.FileTypeFilter.Add(".txt"); IStorageFolder hpf = await folderPicker.PickSingleFolderAsync(); if (hpf == null) { showErrorDialog("You have to choose folder with no blank pokemon pictures. "); shownPath = defaultPath; } else { shownPath = hpf.Path; } OnPropertyChanged("ShownPath"); }
private async void PickFolderButton_Click(object sender, RoutedEventArgs e) { FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add("*"); var folder = await picker.PickSingleFolderAsync(); if (folder == null) { return; } string token = StorageApplicationPermissions.MostRecentlyUsedList.Add(folder); lock (rootFolderSyncRoot) { rootFolder = folder; rootPath = folder.Path; rootFolderBlock.Text = rootPath; ApplicationData.Current.LocalSettings.Values[RootFolderSetting] = token; } }
private async void AddSource() { var picker = new FolderPicker(); picker.FileTypeFilter.Add("*"); picker.ViewMode = PickerViewMode.List; var folder = await picker.PickSingleFolderAsync(); if (folder == null) { return; } var source = new Source { Path = folder.Path, Token = StorageApplicationPermissions.FutureAccessList.Add(folder) }; new SourceService(new SourceRepository()).Add(source); GetAllSources(); }
private async void ProcessImagesClicked(object sender, RoutedEventArgs e) { try { FolderPicker folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { await ProcessImagesAsync(folder); } this.currentRootFolder = folder; } catch (Exception ex) { await Util.GenericApiCallExceptionHandler(ex, "Error picking the target folder."); } }
public async Task <string> PickDeployFolder() { // prepare folder picker FolderPicker folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; folderPicker.FileTypeFilter.Add("*"); // open picker StorageFolder folder = await folderPicker.PickSingleFolderAsync(); // any folder picked if (folder != null) { // save it to access list for future use Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace(DeployFolderToken, folder); // return folder path return(folder.Path); } // user canceled picker return(String.Empty); }
/// <summary> /// /// </summary> /// <returns>the user-selected folder, if any, or null otherwise</returns> private async Task <StorageFolder> LetUserSelectFolder() { // file pickers do not work in snapped mode if (EnsureUnsnapped()) { var picker = new FolderPicker(); picker.SuggestedStartLocation = PickerLocationId.ComputerFolder; picker.FileTypeFilter.Add(".mp3"); var folder = await picker.PickSingleFolderAsync(); if (folder != null) { StoreFolderLocalLibrary.Save(folder); } return(folder); } else { return(null); } }
private async void btnAddPage_Click(object sender, RoutedEventArgs e) { var folderPicker = new FolderPicker(); folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { if (AppSettings.PagesOnStartupList != null) { AppSettings.PagesOnStartupList = AppSettings.PagesOnStartupList.Append(folder.Path).ToArray(); } else { AppSettings.PagesOnStartupList = new string[] { folder.Path }; } CreateAndAddPageItem(folder.Path); } }
private static async void ExportFolderButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { var folderPicker = new FolderPicker { SuggestedStartLocation = PickerLocationId.Downloads }; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder); // Set TextBox text and StorageFolder variable and make primary button clickable ExportFolder = folder; ExportFolderTextBox.Text = folder.Path; ExportDataContentDialog.IsPrimaryButtonEnabled = true; } }
public static async Task <StorageFolder> GetSaveFolder(string content, string title) { string token = "default"; StorageFolder folder = null; try { if (StorageApplicationPermissions.FutureAccessList.ContainsItem(token)) { folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(token); return(folder); } } catch { } MessageDialog dlg = new MessageDialog(content, title); await dlg.ShowAsync(); FolderPicker picker = new FolderPicker(); picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.FileTypeFilter.Add("*"); folder = await picker.PickSingleFolderAsync(); if (folder != null) { StorageApplicationPermissions.FutureAccessList.AddOrReplace(token, folder); } else { folder = ApplicationData.Current.LocalFolder; } return(folder); }
async void OnClick_ChooseFolder(object sender, RoutedEventArgs e) { var folderPicker = new FolderPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.Desktop }; folderPicker.FileTypeFilter.Add(".txt"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { string folderContent = string.Empty; Windows.Storage.AccessCache.StorageApplicationPermissions. FutureAccessList.AddOrReplace("PickedFolderToken", folder); var files = await folder.GetFilesAsync(); foreach (var file in files) { var stream = await file.OpenAsync(FileAccessMode.Read); using (StreamReader reader = new StreamReader(stream.AsStream())) { if (folderContent == string.Empty) { folderContent = reader.ReadToEnd(); } else { folderContent = string.Concat(folderContent, reader.ReadToEnd()); } } } FileContent = folderContent; } }
private async void BtnImportSite_ClickAsync(object sender, RoutedEventArgs e) { FolderPicker folderPicker = new FolderPicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, ViewMode = PickerViewMode.List }; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { // Load from storage folder Site site = await Site.LoadFromFolderAsync(folder); if (_viewModel.GetSiteId(site) >= 0) { // Site exists in the list, ask if it needs to be replaced. ContentDialog dialog = new ContentDialog { Title = "Do you want to overwrite?", Content = "Site " + site.Name + " found in sites repository. Do you want to overwrite it?", PrimaryButtonText = "Yes", SecondaryButtonText = "No", DefaultButton = ContentDialogButton.Secondary }; ContentDialogResult result = await dialog.ShowAsync(); if (result != ContentDialogResult.Primary) { return; } } PageBusy(string.Format("Importing site {0}...", site.Name)); await _viewModel.AddSiteAsync(site); PageReady(); } }
private async void AddFolderToMonitor() { FolderPicker picker = new FolderPicker(); picker.SuggestedStartLocation = PickerLocationId.ComputerFolder; picker.FileTypeFilter.Add(".sln"); var searchFolder = await picker.PickSingleFolderAsync(); if (searchFolder != null) { string uniqueNameForFutureAccessList = $"VsSO_{Guid.NewGuid().ToString()}"; StorageApplicationPermissions.FutureAccessList.AddOrReplace(uniqueNameForFutureAccessList, searchFolder); if (localSettings == null) { localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; } if (localSettings.Values["FutureAccessList_PathIdentifiers"] != null && !string.IsNullOrEmpty(localSettings.Values["FutureAccessList_PathIdentifiers"].ToString())) { List <string> listOfUniquePathFinders = localSettings.Values["FutureAccessList_PathIdentifiers"].ToString().Split(',').ToList(); if (!listOfUniquePathFinders.Any(s => s.Equals(uniqueNameForFutureAccessList))) { listOfUniquePathFinders.Add(uniqueNameForFutureAccessList); } StringBuilder builder = new StringBuilder(); for (int i = 0; i < listOfUniquePathFinders.Count; i++) { builder.Append(listOfUniquePathFinders[i]); if (i < listOfUniquePathFinders.Count - 1) { builder.Append(','); } } localSettings.Values["FutureAccessList_PathIdentifiers"] = builder.ToString(); } else { localSettings.Values["FutureAccessList_PathIdentifiers"] = uniqueNameForFutureAccessList; } } }
private async void BtSerialize_ClickAsync(object sender, RoutedEventArgs e) { myListView.Items.Clear(); var folderPicker = new FolderPicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); try { if (folder != null) { myProgressBar.IsIndeterminate = true; await Task.Yield(); var list = await GetLisFilesAsync(folder, folder.Name); StorageFile storageFile = await folder.CreateFileAsync(folder.Name + ".bin", CreationCollisionOption.GenerateUniqueName); var stream = await storageFile.OpenStreamForWriteAsync(); ZipLib.Serialize.SerializeToBinaryFile(stream, list); } }catch (Exception ex) { var msgDialog = new MessageDialog("Oops!"); await msgDialog.ShowAsync(); Debug.WriteLine("Main Page. 'BtSerialize_ClickAsync' " + ex.Message); } finally { myProgressBar.IsIndeterminate = false; } }
public async void OnBrowseClick(object sender, RoutedEventArgs e) { var picker = new FolderPicker { SuggestedStartLocation = PickerLocationId.MusicLibrary, ViewMode = PickerViewMode.List, }; foreach (var container in Playlist.SupportedContainers) { picker.FileTypeFilter.Add(container); } var folder = await picker.PickSingleFolderAsync(); _tempItems = new List <IStorageItem> { folder }; UpdateFolderFilesCount(_tempItems); if (Title.Length == 0) { Title = folder.DisplayName; } }
/// <inheritdoc/> public async Task <IStorageFolder> RequestFolderAsync(StorageDialogSettings settings) { FolderPicker dialog = new FolderPicker(); if (settings.ShownFileTypes == null || !settings.ShownFileTypes.Any()) { dialog.FileTypeFilter.Add("*"); } else { dialog.FileTypeFilter.AddRange(settings.ShownFileTypes.Select(f => $".{f}")); } if (settings.OverrideSelectText != null) { dialog.CommitButtonText = settings.OverrideSelectText; } var folder = await dialog.PickSingleFolderAsync(); return(new UwpFolder(folder)); }
private async void btSaveAs_Click(object sender, RoutedEventArgs e) { FolderPicker openPicker = new FolderPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.Desktop; openPicker.FileTypeFilter.Add("*"); StorageFolder folder = await openPicker.PickSingleFolderAsync(); if (folder != null) { StorageFile file = await folder.CreateFileAsync("salvo.txt", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, Gerenciador.getRelatorio()); textBox.Text = "Arquivo Salvo com Sucesso!"; textBox.Visibility = Visibility.Visible; btOk.Visibility = Visibility.Visible; controle = "Salvo"; } }
private async void Source_Click(object sender, RoutedEventArgs e) { FolderPicker folderPicker = new FolderPicker { SuggestedStartLocation = PickerLocationId.ComputerFolder }; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { //храним пути до папок var name = "Device" + EditDevice.Id; Windows.Storage.AccessCache.StorageApplicationPermissions. FutureAccessList.AddOrReplace(name, folder); Source.Text = folder.Path; } else { } }
private async void next_Click(object sender, RoutedEventArgs e) { try { FolderPicker folder = new FolderPicker(); folder.FileTypeFilter.Add("*"); storageFolder = await folder.PickSingleFolderAsync(); if (storageFolder != null) { if (NetworkInterface.GetIsNetworkAvailable()) { show_progress(); invisible(); await validate(); hide_progress(); result.Visibility = Visibility.Visible; } else { error += "Oops! Looks like you are not connected to the internet! \nPlease check your internet connection and try again..."; popup(); visible(); next.Visibility = Visibility.Collapsed; } } else { error += "Enter the name of the file to save to..."; popup(); } } catch { } }
public async void OpenSingleFolder() { if (EnsureUnsnapped()) { log("INFO", "OpenSingleFolder..."); selection.Clear(); isBusy = true; try { FolderPicker folderPicker = new FolderPicker(); folderPicker.ViewMode = CurrentViewMode; folderPicker.SuggestedStartLocation = CurrentLocation; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { selection.Add(folder.Path); LastOpenFolder = folder; StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder); } } catch (Exception ex) { log("ERROR", ex.ToString()); } log("INFO", $"OpenSingleFolder end: {selection.Count}"); } else { log("ERROR", "OpenFiles: could not unsnap!"); } isBusy = false; }
private async void decrpt_Click(object sender, RoutedEventArgs e) { try { FileOpenPicker filePicker = new FileOpenPicker(); filePicker.FileTypeFilter.Add("*"); StorageFile temp = await filePicker.PickSingleFileAsync(); StorageFile decrpt = await helper.Decrypt(temp); //helper.popup("File is Decrpted and please select the folder to place the Decrpted file ", "File Decrpted"); FolderPicker folderPicker = new FolderPicker(); folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); StorageFile local = await folder.CreateFileAsync(temp.Name, CreationCollisionOption.GenerateUniqueName); await decrpt.CopyAndReplaceAsync(local); await decrpt.DeleteAsync(); } catch { } }
private async void OpenFolder_OnClick(object sender, RoutedEventArgs e) { var picker = new FolderPicker { CommitButtonText = "Select", ViewMode = PickerViewMode.List }; picker.FileTypeFilter.Add(".idx"); picker.FileTypeFilter.Add(".dz"); picker.FileTypeFilter.Add(".ifo"); picker.SettingsIdentifier = "FolderPicker"; var folder = await picker.PickSingleFolderAsync(); StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder); var abstractFolder = new PCLStorage.WinRTFolder(folder); using (var dict = new StarDict(abstractFolder, @"dictd_www.freedict.de_eng-nld")) { await dict.Init(); } }
private async void DownloadAll(string urls) { ButtonText = "Downloading"; List <StorageFile> downloadedFiles = new List <StorageFile>(); FolderPicker folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.Downloads; folderPicker.ViewMode = PickerViewMode.List; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); DownloadOperation downloadOperation; String[] urlList = urls.Split(','); try { await Task.Run(() => { Parallel.ForEach <string>(urlList, async(url) => { var fileName = Helper.GetFileName(url); string fileExtension = url.Substring(url.LastIndexOf('.')); StorageFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); downloadOperation = backgroundDownloader.CreateDownload(new Uri(url), file); Progress <DownloadOperation> progress = new Progress <DownloadOperation>(progressChanged); cancellationToken = new CancellationTokenSource(); await downloadOperation.StartAsync().AsTask(cancellationToken.Token, progress); }); }); MessageText = "Visit here: " + folder.Path; ButtonText = "CancelAll"; ButtonClickCommand = CancelAllCmd; } catch (Exception ex) { } }
private async void BtnStop_Click(object sender, RoutedEventArgs e) { recording = false; if (band != null && band.Events.Count > 0) { Debug.WriteLine("Logging File"); StringBuilder csv = new StringBuilder(); foreach (var evt in band.Events) { // C# 6.0 feature. csv.AppendLine($"{evt.UnixTimeSecondsDotMilliseconds},{evt.GSR}"); } // Because this is an universal app, we have some constraints on how we can access the file system. // http://stackoverflow.com/questions/33082835/windows-10-universal-app-file-directory-access FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add(".csv"); StorageFolder folder = await picker.PickSingleFolderAsync(); StorageFile file = await folder.CreateFileAsync("EDA_" + DateTime.Now.ToFileTime() + ".csv"); await WriteAllTextAsync(file, csv.ToString()); } }
private async void btnPickFolder_Click(object sender, RoutedEventArgs e) { // 选择一个文件夹 FolderPicker folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = PickerLocationId.Desktop; folderPicker.FileTypeFilter.Add(".docx"); folderPicker.FileTypeFilter.Add(".xlsx"); folderPicker.FileTypeFilter.Add(".pptx"); // 弹出文件夹选择窗口 StorageFolder folder = await folderPicker.PickSingleFolderAsync(); // 用户在“文件夹选择窗口”中完成操作后,会返回对应的 StorageFolder 对象 if (folder != null) { lblMsg.Text = "选中文件夹: " + folder.Name; } else { lblMsg.Text = "取消了"; } }
public async void SearchForSolutions() { var configurationStored = await Serializer.LoadConfiguration <ObservableCollection <Solution> >(); if (configurationStored != null) { solutions = configurationStored; solutionsGrid.ItemsSource = solutions; } else { StorageFolder searchFolder; if (StorageApplicationPermissions.FutureAccessList.ContainsItem("VsSolutionOrganizerBaseSearchPath")) { searchFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync("VsSolutionOrganizerBaseSearchPath"); } else { FolderPicker picker = new FolderPicker(); picker.SuggestedStartLocation = PickerLocationId.ComputerFolder; picker.FileTypeFilter.Add(".sln"); searchFolder = await picker.PickSingleFolderAsync(); if (searchFolder != null) { StorageApplicationPermissions.FutureAccessList.AddOrReplace("VsSolutionOrganizerBaseSearchPath", searchFolder); } } if (searchFolder != null) { foreach (var solutionFolder in await searchFolder.GetFoldersAsync()) { solutions.Add(new Solution { id = Guid.NewGuid().ToString(), name = solutionFolder.Name, stauts = StatusOfSolution.InDevelop, tags = new List <string>() }); } } } }
private async void AddMusicToLibrary_ClickAsync(object sender, RoutedEventArgs e) { FolderPicker folderPicker = new FolderPicker() { SuggestedStartLocation = PickerLocationId.MusicLibrary }; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { LibraryLoader.LibraryLoader libraryLoader = new LibraryLoader.LibraryLoader(); libraryLoader.ProgressUpdated += this.LibraryLoader_ProgressUpdated; this.AddingSongsToLibraryContainer.Visibility = Visibility.Visible; libraryLoader.AddPath(folder); await libraryLoader.ReloadAllPathsAsync(); this.AddingSongsToLibraryContainer.Visibility = Visibility.Collapsed; } }
internal static async Task ExportCollectionToFolderAsync(List <InstalledFont> fontList, UserFontCollection selectedCollection) { var fonts = fontList.SelectMany(f => f.Variants).ToList(); FolderPicker picker = new FolderPicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; picker.FileTypeFilter.Add("*"); if (await picker.PickSingleFolderAsync() is StorageFolder folder) { await Task.Run(async() => { var interop = SimpleIoc.Default.GetInstance <Interop>(); foreach (var font in fonts) { if (interop.GetFileBuffer(font.FontFace) is FontFileData d) { StorageFile file = await folder.CreateFileAsync(CleanFileName(font, d.FileName), CreationCollisionOption.ReplaceExisting); using var stream = await file.OpenStreamForWriteAsync(); stream.SetLength(0); DataWriter w = new DataWriter(stream.AsOutputStream()); w.WriteBuffer(d.Buffer); await w.StoreAsync(); await w.FlushAsync(); d.Dispose(); } } }); Messenger.Default.Send(new AppNotificationMessage(true, new ExportFontFileResult(true, folder))); } }
/// <summary> /// 修改存储路径 /// </summary> private async Task Folder_ClickAsync()//修改存储路径 { FolderPicker picker = new FolderPicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add("*"); StorageFolder folder = await picker.PickSingleFolderAsync(); if (folder != null) { Temp_Filelocal = folder.Path; } if (Temp_Filelocal != null) { string localFolder = ApplicationData.Current.LocalFolder.Path; string dbFullPath = Path.Combine(localFolder, MainPage.dbname); // 建立连接 using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), dbFullPath)) { //conn.DeleteAll<Person>(); // 插入数据 UserItem[] stus = { new UserItem { FilePath = Temp_Filelocal } }; int n = conn.InsertAll(stus); WriteLine($"已插入 {n} 条数据。"); //读取数据 // 获取列表 TableQuery <UserItem> t = conn.Table <UserItem>(); var Result = t.LastOrDefault(); FileLocal.Text = Result.FilePath; // 绑定 } } }
private IAsyncOperation<StorageFolder> SelectFolderAsync( SelectFolderInteraction selectFolder ) { Contract.Requires( selectFolder != null ); Contract.Ensures( Contract.Result<IAsyncOperation<StorageFolder>>() != null ); var commitButton = selectFolder.DefaultCommand; var dialog = new FolderPicker(); dialog.FileTypeFilter.AddRange( selectFolder.FileTypeFilter ); dialog.SuggestedStartLocation = SuggestedStartLocation; dialog.ViewMode = ViewMode; if ( dialog.FileTypeFilter.Count == 0 ) dialog.FileTypeFilter.Add( "*" ); if ( !string.IsNullOrEmpty( SettingsIdentifier ) ) dialog.SettingsIdentifier = SettingsIdentifier; if ( commitButton != null ) dialog.CommitButtonText = commitButton.Name; return dialog.PickSingleFolderAsync(); }