locked
Launcher.LaunchFileAsync and saveability in the LocalFolder of the caller app

    Question

  • I have some Files (e.g. text file, word file, ..) in an LocalFolder and open it with:

    StorageFolder localFolder = ApplicationData.Current.LocalFolder;

    var file = await localFolder.GetFileAsync("example.txt");

    var options = new LauncherOptions {DisplayApplicationPicker = true};

    Launcher.LaunchFileAsync(file, options);


    This opens the file with an app assotiated with the file content-type. But how can I tell the launched app, that the file could be saved to the LocalFolder of my app? (For example the OneDrive app, it downloads a file from the cloud, opens it in Texteditor, and save it to the cloud)

    Monday, December 15, 2014 10:40 AM

All replies

  • declaration FileSavePicker

    refer to : Quickstart: Integrating with file picker contracts (Windows Runtime apps)

    Decide which services your app will provide from file picker windows

    Your app can provide the following services to other apps by
    integrating with the associated app contract. To participate in a
    contract, you must declare the contract in your app manifest, respond to
    the corresponding activated event, and create a specialized app view.


    Provide access to files

    Make files accessible from a file picker if your app has a unique
    and/or valuable view of those files or if users cannot easily access the
    files another way.

    App contract: File Open Picker contract

    Activated event information: fileOpenPickerActivatedEventArgs



    Provide a save location

    Provide a save location through a file picker if you expect your
    users to want to save files in order to  open and work with them in your
    app later.

    App contract: File Save Picker contract

    Activated event information: fileSavePickerActivatedEventArgs



    Provide real-time updates for files

    Track and update files through a file picker if you expect users to
    use your app as a central repository of files that your app provides
    access to, or that are saved using your app as the save location.

    App contract: Cached File Updater contract

    Activated event information: cachedFileUpdaterActivatedEventArgs





    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Monday, December 15, 2014 3:45 PM
  • Hello Bill,

    thank you for reply. I have tested the last days your hints but don't find a working solution.

    I have added the CachedFileUpdater.SetUpdateInformation call before launching an external app with the file, but still can't save the file in the e.g. texteditor - message: file is opend in read-only mode.

    CachedFileUpdater.SetUpdateInformation(file, "someId", ReadActivationMode.BeforeAccess,
    WriteActivationMode.AfterWrite, CachedFileOptions.None);
    Launcher.LaunchFileAsync(file);
    I don't want that my app is on FileSavePicker, only that I can open the file direct in my app and the file get routed to an external app (like it seems to be in the OneDrive app). Have you some more ideas to archive this behavior?

    Wednesday, December 17, 2014 12:56 PM