private void TrySaveAudio(string audioFileName) { var picker = new FileSavePicker(); picker.ContinuationData.Add("OriginalFileName", audioFileName); picker.FileTypeChoices["Audio files"] = new List<string> { ".wav" }; picker.SuggestedFileName = Path.GetFileNameWithoutExtension(audioFileName); picker.DefaultFileExtension = ".wav"; picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.PickSaveFileAndContinue(); }
private void SaveFileButton_Click(object sender, RoutedEventArgs e) { // Clear previous returned file name, if it exists, between iterations of this scenario OutputTextBlock.Text = ""; FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = "New Document"; savePicker.PickSaveFileAndContinue(); }
private async void ExportMenuFlyoutItem_Click(object sender, RoutedEventArgs e) { var timetable = (TimetableDescription)((FrameworkElement)sender).DataContext; if (timetable.FileName == App.Timetable.FileName) await TimetableIO.SaveTimetable(App.Timetable); var picker = new FileSavePicker(); string invalidChars = System.Text.RegularExpressions.Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars())); string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars); picker.SuggestedFileName = System.Text.RegularExpressions.Regex.Replace(timetable.Name, invalidRegStr, "_"); picker.FileTypeChoices.Add("XML", new List<string>() { ".xml" }); picker.ContinuationData.Add("FileName", timetable.FileName); picker.PickSaveFileAndContinue(); }
private void BackupButton_Click(object sender, RoutedEventArgs e) { if (App.Locator.Download.ActiveDownloads.Count > 0) { CurtainPrompt.ShowError("Can't do a backup while there are active downloads."); return; } var savePicker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("Audiotica Backup", new List<string> { ".autcp" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = string.Format("{0}-WP81", DateTime.Now.ToString("MM-dd-yy_H.mm")); savePicker.PickSaveFileAndContinue(); }
private async void SaveToFileButton(object sender, RoutedEventArgs e) { FileSavePicker savePicker = new FileSavePicker() { SuggestedFileName = string.Format("TextDocument-{0}", DateTime.Now.ToString("dd-MMM-yyyy")), FileTypeChoices = { { "Plain text", new List<string>{ ".txt" }}, { "Web Page", new List<string>{ ".html", ".htm" }} }, SuggestedStartLocation = PickerLocationId.DocumentsLibrary, CommitButtonText = "Save my text document" }; #if WINDOWS_APP StorageFile saveFile = await savePicker.PickSaveFileAsync(); await SaveTextFile(saveFile); #elif WINDOWS_PHONE_APP savePicker.PickSaveFileAndContinue(); #endif }
public void saveFile(string fileName, byte[] fileContents) { FileSavePicker picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.Downloads; string extension, name; extension = name = ""; for (int i = fileName.Length - 1; i >= 0; i--) { if (fileName[i] == '.') { extension = fileName.Substring(i); name = fileName.Substring(0, i); break; } } if (extension == ".") extension += "noex"; if (extension == "") extension = ".noex"; if (name == "") name = fileName; picker.FileTypeChoices.Add("Downloaded file", new List<string>() { extension }); picker.SuggestedFileName = name; fileContentsToWrite = fileContents; picker.PickSaveFileAndContinue(); }
private async void OnSaveClick(object sender, RoutedEventArgs e) { var picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.DefaultFileExtension = ".png"; picker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("Bitmap image", new[] { ".bmp" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("Png image", new[] { ".png" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("Jpeg image", new[] { ".jpg", ".jpe", ".jpeg" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("Gif image", new[] { ".gif" }.ToList())); #if WINDOWS_PHONE_APP picker.ContinuationData["operation"] = MainPageOperation.Save.ToString(); picker.PickSaveFileAndContinue(); #else var file = await picker.PickSaveFileAsync(); if (file != null) { this.OnSave(file); } #endif }
public async Task SaveAsync(IStorageFile file) { var picker = new FileSavePicker { SuggestedFileName = file.Name, }; var extension = Path.GetExtension(file.Name); if (string.IsNullOrEmpty(extension)) extension = ".unknown"; picker.FileTypeChoices.Add("Attachment File", new List<string> {extension}); #if WINDOWS_PHONE_APP picker.ContinuationData.Add("Source", file.Path); picker.PickSaveFileAndContinue(); #else var target = await picker.PickSaveFileAsync(); await Continue(FilePickTargets.Attachments, file, target); #endif }
private Task<StorageFile> SaveFileAsync(IRandomAccessStream stream) { // See http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614994.aspx // For ContinuationManager complete implementation. // A smaller version of this is also available in the sample and in the App.xaml.cs. var tcs = new TaskCompletionSource<StorageFile>(); EventHandler<FileSavePickerContinuationEventArgs> fileSavedHandler = null; fileSavedHandler = (s, e) => { ContinuationManager.Current.FilePickerSaved -= fileSavedHandler; var file = e.File; if (file == null) tcs.TrySetCanceled(); else tcs.TrySetResult(file); }; ContinuationManager.Current.FilePickerSaved += fileSavedHandler; FileSavePicker filePicker = new FileSavePicker(); filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; filePicker.FileTypeChoices.Add("ZIP", new List<string>() { ".zip" }); filePicker.DefaultFileExtension = ".zip"; filePicker.SuggestedFileName = "Output"; filePicker.PickSaveFileAndContinue(); return tcs.Task; }
private void exportButton_Click(object sender, RoutedEventArgs e) { exportDatabase = true; FileSavePicker picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.ContinuationData["Operation"] = "ExportDatabase"; picker.FileTypeChoices.Add("TextFile", new List<string>() { ".txt" }); String time = DateTime.Now.ToString(); time = time.Replace(' ', '_'); time = time.Replace(":", ""); time = time.Replace(".", ""); String fileName = "NihongoSenpaiExport_" + time; picker.SuggestedFileName = fileName; picker.PickSaveFileAndContinue(); }
private async void SaveAs_Click(object sender, RoutedEventArgs e) #endif { FileSavePicker picker = new FileSavePicker(); picker.FileTypeChoices.Add("JPEG image", new string[] { ".jpg" }); picker.FileTypeChoices.Add("PNG image", new string[] { ".png" }); picker.FileTypeChoices.Add("BMP image", new string[] { ".bmp" }); picker.DefaultFileExtension = ".png"; picker.SuggestedFileName = "Output file"; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; // On Windows Phone, after the picker is launched the app is closed. #if WINDOWS_PHONE_APP picker.PickSaveFileAndContinue(); #else var file = await picker.PickSaveFileAsync(); if (file != null) { await LoadSaveFileAsync(file); } #endif }
private void SaveImage(FileSavePicker savePicker) { savePicker.PickSaveFileAndContinue(); }
private void StartSavePhotoFile() { var filenameFormat = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("PhotoSaveFilenameFormat"); var filename = String.Format(filenameFormat, DateTime.Now.ToString("yyyyMMddHHmmss")); var picker = new FileSavePicker(); picker.SuggestedFileName = filename; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeChoices.Add(".jpg", new List<string>() { ".jpg" }); picker.ContinuationData["Operation"] = "SavePhotoFile"; picker.PickSaveFileAndContinue(); App.ContinuationEventArgsChanged += App_ContinuationEventArgsChanged; }
/////////////////////////////////////////////////////////////////////////// // Use the FileSavePicker to save the photo with the selected file name private void AppBarBtnSave_Click(object sender, RoutedEventArgs e) { var fsp = new FileSavePicker { DefaultFileExtension = ".jpg", SuggestedFileName = "editedPhoto.jpg", SuggestedStartLocation = PickerLocationId.PicturesLibrary, }; fsp.FileTypeChoices.Add("JPEG", new List<string> { ".jpg" }); fsp.PickSaveFileAndContinue(); }
private void SaveTweaksButton_Click(object sender, EventArgs e) { var savePicker = new FileSavePicker() { DefaultFileExtension = ".xml", SuggestedFileName = "Tweaks.xml", }; savePicker.FileTypeChoices.Add("XML file", new List<string>() { ".xml" }); savePicker.PickSaveFileAndContinue(); }
/// <summary> /// /// </summary> /// <param name="imageBuffer"></param> /// <returns></returns> public async Task<bool> SaveImageFileAsync(IBuffer imageBuffer) { _imageBuffer = imageBuffer; bool success = false; var picker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.PicturesLibrary }; picker.FileTypeChoices.Add(JpegFileTypeDescription, _supportedSaveImageFilePostfixes); picker.SuggestedFileName = "FE_" + FormattedDateTime() + _supportedSaveImageFilePostfixes[0]; System.Diagnostics.Debug.WriteLine(DebugTag + "SaveImageFile(): Suggested filename is " + picker.SuggestedFileName); #if WINDOWS_PHONE_APP picker.ContinuationData["Operation"] = SelectDestinationOperationName; picker.PickSaveFileAndContinue(); success = true; #else StorageFile file = await picker.PickSaveFileAsync(); if (file != null) { success = await SaveImageFileAsync(file); NameOfSavedFile = file.Name; } #endif return success; }