Alexandru
Alexandru

Reputation: 12892

How to automatically load previously used files on Windows Store app startup

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?

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.

Upvotes: 0

Views: 223

Answers (1)

Rob Caplan - MSFT
Rob Caplan - MSFT

Reputation: 21899

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

Upvotes: 3

Related Questions