如何在Windows应用商店应用启动时自动加载以前使用的文件 [英] How to automatically load previously used files on Windows Store app startup

查看:153
本文介绍了如何在Windows应用商店应用启动时自动加载以前使用的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Store应用程序开发中发现了一个场景,各种网站表明是不可能的。有人可以确认,如果在Windows应用商店的应用程序中可以做到以下几点,以及如何以编程方式完成?




  • 用户点击加载文件按钮加载文档,用标准Metro FilePicker 显示,选择一个文档,文件加载进入应用程序进行编辑。该应用程序以某种方式保存路径到这个文件或一些其他的资源,使文件自动地在将来的应用程序启动打开。

  • 用户重新启动应用程序
  • 启动时,应用程序加载最近打开的文档,自动向用户显示,以便再次进行编辑向用户展示另一个 FilePicker )。用户对文档进行了更改,在键盘上点击 Control + S ,并自动将更改保存到文件中。




  • 我已经在我当前的应用程序中尝试了这一点,但似乎从OneDrive自动加载文件路径不起作用(我得到一个 System.UnauthorizedAccessException:访问被拒绝。)。在线上,我已经阅读了包括文档功能(允许我访问我的OneDrive文件)将不会允许我的应用程序获得批准,因为我需要批准,这不是我的可能性。

    解决方案

    你不能从路径中重构任意的访问。您需要挂上StorageFile以保持其访问权限。要缓存跨会话,请使用Windows.Storage.AccessCache类,例如StorageApplicationPermissions.FutureAccessList和MostRecentlyUsedList。

    这些将允许您保存选择器授予的权限应用程序重新启动。



    我将在 http://blogs.msdn.com/b/wsdevsol/archive/2012/12/05/stray -from-the-path-stick-to-the-storagefile.aspx

    I've come across a scenario in my Windows Store app development that various websites indicate is not possible. Can someone please confirm if the following is possible in a Windows Store app and how it can be done programmatically?

    • User taps on a "Load File" button to load a document, is presented with the standard Metro FilePicker, selects a document, and the file loads into the application for editing. The application somehow saves the path to this file or some other resource that would allow the file to be automatically opened on a future application start.
    • User restarts the application by closing it and then opening it.
    • On startup, the application loads the most recently opened document and automatically presents the user with it for editing again (without having to present the user with another FilePicker). The user makes changes to the document, hits Control + S on the keyboard, and changes are automatically saved to the file.

    I have tried this in my current application, but it seems that loading a file path automatically from OneDrive does not work (I get a System.UnauthorizedAccessException: Access is denied.). Online, I've read that including the documents capability (which would allow me access to my OneDrive file) will not allow my application to get approval, and since I need approval, this is not a possibility for me.

    解决方案

    You cannot reconstitute arbitrary for access from a path. You need to hang on to the StorageFile to keep its access. To cache the across sessions use the Windows.Storage.AccessCache classes such as StorageApplicationPermissions.FutureAccessList and MostRecentlyUsedList.

    These will let you save the permissions granted by the picker to reuse when the app restarts.

    I discuss this in more detail at http://blogs.msdn.com/b/wsdevsol/archive/2012/12/05/stray-from-the-path-stick-to-the-storagefile.aspx

    这篇关于如何在Windows应用商店应用启动时自动加载以前使用的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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