/// <summary> /// Shows the file picker so that the user can save a file and set the file name, /// extension, and location of the file to be saved. /// </summary> /// <param name="settings">The settings for the file save picker.</param> /// <returns> /// When the call to this method completes successfully, it returns a /// <see cref="StorageFile" /> object that was created to represent the saved file. The file /// name, extension, and location of this <see cref="StorageFile" /> match those specified /// by the user, but the file has no content. /// </returns> public IAsyncOperation <StorageFile> PickSaveFileAsync(FileSavePickerSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } Logger.Write($"Commit button text: {settings.CommitButtonText}"); var dialog = new FileSavePickerWrapper(settings); return(dialog.PickSaveFileAsync()); }
private async void SaveFile() { var settings = new FileSavePickerSettings { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, FileTypeChoices = new Dictionary <string, IList <string> > { { "Text Documents", new List <string> { ".txt" } } }, DefaultFileExtension = ".txt" }; StorageFile storageFile = await dialogService.PickSaveFileAsync(settings); if (storageFile != null) { Path = storageFile.Path; } }
async void SaveImageMethod() { //Setup metadata. var metaData = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>( "Format", "png" ), new KeyValuePair <string, string>( "Application Name", "Reconstruction and Calibration Tool (UWP)" ), new KeyValuePair <string, string>( "Camera Manufacturer", "Centice" ), new KeyValuePair <string, string>( "Exposure Time", ExposureTime.ToString() ), new KeyValuePair <string, string>( "Laser enabled", IsLaserChecked.ToString() ), new KeyValuePair <string, string>( "Values scaled", IsScaledChecked.ToString() ), new KeyValuePair <string, string>( "Min value", MinValue ), new KeyValuePair <string, string>( "Max value", MaxValue ) }; if (SaveAmount == 1) { var saveFileSettings = new FileSavePickerSettings { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, FileTypeChoices = new Dictionary <string, IList <string> > { { "PNG Images", new List <string> { ".png" } } }, DefaultFileExtension = ".png" }; StorageFile storageFile = await _dialogService.PickSaveFileAsync(saveFileSettings); if (storageFile != null) { StorageFile img = await Imaging.WriteableBitmapToStorageFile(_lastImageArray, IsScaledChecked, metaData); await img.CopyAndReplaceAsync(storageFile); } } else { //Disable Buttons. SaveImageButtonEnabled = false; GetImageButtonEnabled = false; //Get folder to save imgs. var folderPickerSettings = new FolderPickerSettings { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, FileTypeFilter = new List <string> { ".png" } }; StorageFolder storageFolder = await _dialogService.PickSingleFolderAsync(folderPickerSettings); //GetImage, Save, Loop. for (uint i = 0; i < SaveAmount; i++) { try { Image = await GetImageFromCamera(); } catch (Exception) { // ignored } StorageFile img = await Imaging.WriteableBitmapToStorageFile(_lastImageArray, IsScaledChecked, metaData); string strDateTime = DateTime.Now.ToString("yyyyMMdd-HHmmss-"); await img.CopyAsync(storageFolder, strDateTime + "img" + i + ".png"); } SaveImageButtonEnabled = true; GetImageButtonEnabled = true; } }
public IAsyncOperation <StorageFile> PickSaveFileAsync(FileSavePickerSettings settings) { throw new NotImplementedException(); }