如何在不使用FilePicker的固定位置保存和加载InkCanvas gif文件 [英] How to save and load InkCanvas gif file at fixed location without FilePicker

查看:134
本文介绍了如何在不使用FilePicker的固定位置保存和加载InkCanvas gif文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要保存并加载InkCanvas gif文件而不使用FilePicker.

I want to save and load InkCanvas gif file without FilePicker.

我看到了示例使用FilePicker,但是我想在单击保存"按钮时自动保存gif文件.

I saw a sample using FilePicker, but I want to save the gif file automatically when I click the save button.

例如,当我保存1个InkCanvas gif文件时,

For example, when I save 1 InkCanvas gif file,

然后gif文件保存在C:驱动器上的特定文件夹中.

Then the gif file is saved at in a specific folder on my C: drive.

我还希望文件名自动增长,以便可以加载特定的InkCanvas文件.

I also want the file name grow automatically, so that I can load specific InkCanvas file.

这可能吗?

推荐答案

UWP应用程序在沙箱中运行,以便用户可以知道该应用程序在做什么以及它可以访问其硬盘上的哪些文件.

UWP apps run in a sandbox, so that the user can know what the app is doing and which files on her hard drive it accesses.

如果要将文件保存到用户硬盘驱动器上的某个位置,则必须首先获得对该位置的访问权限.有几种方法可以实现此目的:

In case you want to save files to a location on the user's hard drive, you will have to be given access to this location first. There are several options how to achieve this:

  1. FileSavePicker -您发现的选项,但是它要求用户每次手动选择目标文件.如果要在下次打开应用程序时访问选定的文件,则可以使用FutureAccessList ,您可以在其中将StorageFile存储在密钥下,这将允许您下次再次检索它.
  2. FolderPicker -让用户使用对话框选择应在其中存储图像的文件夹,您将获得对该文件夹的读/写权限.然后,您可以根据需要在此处轻松创建新文件.如果您想在下次打开应用程序时访问此选定的位置,则可以使用FutureAccessList ,您可以在其中将StorageFolder存储在密钥下,这将允许您下次再次检索它.
  3. 图片库 -您的应用可以在 package.appxmanifest 文件中声明picturesLibrary功能,然后访问用户的图片库以编写如下内容:Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Pictures);
  4. 广泛的文件系统访问 -这是最终"解决方案,需要您的应用进行定位Windows 10的Spring Creators Update(即将于2018年4月发布)或更高版本.您必须在应用清单中声明broadFileSystemAccess功能,然后才能直接访问用户有权访问的任何文件系统路径.唯一的问题是,您需要有充分的理由(例如构建文件浏览器应用程序或类似程序),因为在Microsoft Store认证期间会检查此功能,并且如果对于您要发布的应用程序类型,似乎不需要此功能.
  1. FileSavePicker - the option you have discovered, but it requires the user to select the destination file each time manually. If you want to access the selected file next time the app is opened, you can utilize FutureAccessList, where you can store the StorageFile under a key, which will allow you to retrieve it again next time.
  2. FolderPicker - let the user select the folder where the images should be stored using a dialog, and you will get read/write permission to this folder. You can then easily create new files there as you require. If you want to access this selected location next time the app is opened, you can utilize FutureAccessList, where you can store the StorageFolder under a key, which will allow you to retrieve it again next time.
  3. Pictures library - your app can declare the picturesLibrary capability in the package.appxmanifest file and then get access to the user's pictures library for writing like this: Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Pictures);
  4. Broad file system access - this is the "ultimate" solution and requires your app to target the Spring Creators Update of Windows 10 (pending release in April 2018) or later. You must declare the broadFileSystemAccess capability in your app's manifest and then you can directly access any filesystem path the user has access to. The only problem with this is that you need to have a good reason to do this (like building a file explorer app, or similar), because this capability is checked during Microsoft Store Certification and it is possible that your app would get rejected if the presence of this capability would seem unnecessary for the type of application you are publishing.

这篇关于如何在不使用FilePicker的固定位置保存和加载InkCanvas gif文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆