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.

How to create and write to .txt file

How do you create a .txt file which we can then use to write information about the users position to.

Tagged:

Answers

  • The following code will write to your application's local folder where you have write and read access. another plus is you know the exact path when you load it at run time.
    //Get local folder StorageFolder storageFolder = ApplicationData.Current.LocalFolder; //Create file StorageFile textFileForWrite = await storageFolder.CreateFileAsync("Myfile.txt", CreationCollisionOption.ReplaceExisting); //Write to file await FileIO.WriteTextAsync(textFileForWrite, newFile); //Get file StorageFile textFileForRead = await storageFolder.GetFileAsync("Myfile.txt"); //Read file string plainText = ""; plainText = await FileIO.ReadTextAsync(textFileForRead); Debug.Log("New file written: " + plainText);

    if you want to access the streaming assets folder at runtime from the hololens you can also do this
    StorageFolder dataFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Data"); StorageFolder streamingAssetsFolder = await dataFolder.GetFolderAsync("StreamingAssets");

    then you can call GetFileAsync() to get a file you have there (I am unsure about being able to write there which is why I write my file to the LocalFolder)

Sign In or Register to comment.