I have a WinRT Metro app (XAML/C#, Windows Release Preview) that manages documents. The documents are represented in-memory and fetched via a Web Service, but are not physically stored on disk.
To improve my app I wanted to implement the FileSavePicker contract. Thus other apps could save their documents directly into my app. But it doesn’t seem possible to get the content from the file save picker in memory into my app. I have attached an event handler to the FileSavePickerActivatedEventArgs.FileSavePickerUI.TargetFileRequested event that is fired when the user wants to save a file to my app. But here I have to set TargetFileRequestedEventArgs.Request.TargetFile to a StorageFile and since I’m in memory and don’t have a file yet, this action fails.
Furthermore (even if I would have a StorageFile) I have to react on the completion of the file saving process and there seems to be no method/event that I could take to handle this.
I don’t understand why Microsoft decided to go this API way for the file save picker contract. Why can’t I get the saved data/file as parameter/stream and do what I want? Sandboxing/security can’t be the reason in this case!
Edit: I’ve seen and looked at the file picker contracts sample app from the SDK, but it doesn’t help, since it only saves to a physical StorageFile.
Have you looked at the CachedFileUpdater contract? You can use this to receive notifications when the source app makes writes to the file. You would still need to create a StorageFile for this.