Answered by:
StorageFile on WinRT

Question
-
I understand that in WinRT you have limited access to files only in predetermined folders. However with the file picker you are allowed to touch files in other folders as well and I got that working fine.
As my app is some kind of an editor, I want to remember what file a person was working with before the app was closed for whatever reason, so that I can load that actual file during startup. Unfortunately that is not possible as I no longer have access to that location without having to use the picker again. Is there a way around this? Or should I just save the changes to the file at shutdown?
Thursday, November 22, 2012 7:54 AM
Answers
-
I figured it out. This is obviously done by adding the file to the MRU (MostRecentlyUsed file list) and in the next start up query it from there.
- Marked as answer by jbroekhu Thursday, November 22, 2012 5:15 PM
Thursday, November 22, 2012 5:14 PM
All replies
-
I figured it out. This is obviously done by adding the file to the MRU (MostRecentlyUsed file list) and in the next start up query it from there.
- Marked as answer by jbroekhu Thursday, November 22, 2012 5:15 PM
Thursday, November 22, 2012 5:14 PM -
Thanks, that was not obvious to me. http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh972344(v=win.10).aspx indicates that a token is used to retrieve a StorageFile ^.
- Edited by Andrew7Webb Thursday, November 22, 2012 6:42 PM .
Thursday, November 22, 2012 6:40 PM -
Yes, you get that token as a return value from the Add function. You can store that token as string for later retrieval or in case of my simple app, just query the most recently used file (first in the list):
auto entries = StorageApplicationPermissions::MostRecentlyUsedList->Entries; if ( entries->Size > 0 ) { IIterator<AccessListEntry>^ it = entries->First(); auto token = it->Current.Token; create_task(StorageApplicationPermissions::MostRecentlyUsedList->GetFileAsync(token)).then([=](StorageFile^ file) { } }
Friday, November 23, 2012 7:19 PM