Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

I can't get FileSavePicker to function with my HoloLens

I noticed in
[https://developer.microsoft.com/en-us/windows/holographic/App_model.html#known_folders
that they cite the following statement:-

File pickers
HoloLens supports both FileOpenPicker and FileSavePicker contracts. However, no app comes pre-installed that fulfills the file picker contracts. These apps - OneDrive, for example - can be installed from the Windows Store.

Not sure what this means exactly. I just need to know how to Load and Save a file correct.y on HoloLens! As a test, I took the plunge and added a new routine into my utility class with the following extra user statements:-

using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.Storage.Provider;

Then I added the code:-

    static async public void useFileSavePicker()
    {
        FileSavePicker savePicker = new FileSavePicker();
        savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
        // Dropdown of file types the user can save the file as
        savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" });
        // Default file name if the user does not type one in or select a file to replace
        savePicker.SuggestedFileName = "New Document";

        StorageFile file = await savePicker.PickSaveFileAsync();
        if (file != null)
        {
            // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
            CachedFileManager.DeferUpdates(file);
            // write to file
            await FileIO.WriteTextAsync(file, file.Name);
            // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
            // Completing updates may require Windows to ask for user input.
            FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
            if (status == FileUpdateStatus.Complete)
            {
                datagramsocket.message_to_send = "File " + file.Name + " was saved.";
            }
            else
            {
                datagramsocket.message_to_send = "File " + file.Name + " couldn't be saved.";
            }
        }
        else
        {
            datagramsocket.message_to_send = "Operation cancelled.";
        }
    }

If you create your own app to test this,

datagramsocket.message_to_send =...

is my way of getting information (now and again) to my PC so I can examine what's happening. This stuff I cribbed mainly from an existing example.

My App works well until I invoke this routine and then it crashes out without any explanation. Whatever am I doing wrong?

As mentioned in earlier Q & A's I tried
StorageApplicationPermissions.FutureAccessList

as in:-

    static public string Find_FALtoken_from_accesslist_metadata(string filename)
    {
        var fname = filename.ToLower();
        string token = "";
        AccessListEntryView entries;
        entries = StorageApplicationPermissions.FutureAccessList.Entries;
        //datagramsocket.message_to_send = "entries: " + entries.ToString();
        foreach (AccessListEntry entry in entries)
        {
            var name = entry.Metadata;
            //datagramsocket.message_to_send = "stored name: " + name;
            if (name.ToLower().Equals(fname))
            {
                token = entry.Token;
                return token;
            }
        }
        return token;
    }

to pick a token from a file in the dictionary without success.

So far after weeks of trying I am despairing of being able to save any of my own stuff (serialized XML) in any folder known or otherwise! If someone (like Patrick) can give me enlightenment and show me an example of a single text line being saved and loaded after a reset I would be very very grateful. I think I would nominate him/her to be made a living saint!!

Best Answer

Answers

  • @wheelchairman said:

    File pickers
    HoloLens supports both FileOpenPicker and FileSavePicker contracts. However, no app comes pre-installed that fulfills the file picker contracts. These apps - OneDrive, for example - can be installed from the Windows Store.

    Not sure what this means exactly. I just need to know how to Load and Save a file correct.y on HoloLens! As a test, I took the plunge and added a new routine into my utility class with the following extra user statements:-

    Did you install the "OneDrive" app on your HoloLens?

    Did you build your Unity app with the UWP Build Type set to: XAML ?

    If you are looking for a really simple example (doesn't use FilePickers) of how to read/write a file in the local app directory, this post might be of interest.

    HTH

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • I'm using FileSavePicker from here and it works:
    https://www.assetstore.unity3d.com/en/#!/content/54715
    Unfortunately it's paid plugin :(

  • Thank you @HoloSheep. Yes I just installed OneDrive SDK into my Visual Studio via Nugent. Just absorbing it currently. No I didn't set the Build Type to XAML unfortunately as I like D3D best. Is this an issue now? Thank you again for your help.

    Thank you @NeatWare_FUBAR77 I shall look at that.

  • @wheelchairman not sure you need the "OneDrive SDK", I think you just need to install the client app on the HoloLens.

    It is my understanding that the FilePickers are XAML based UI's and like the virtual keyboard require you to create your Unity app with the Build Type of XAML in order to get them to show.. however I could be wrong.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

Sign In or Register to comment.