Search code examples
javascriptc#filewindows-10-universalstoragefile

Simplest way to read a StorageFile end-to-end into a string?


I have a StorageFile object I'm trying to read into a string (for debugging purposes). What's the simplest way to do that?


Solution

  • In C#:

    string text = await Windows.Storage.FileIO.ReadTextAsync(storageFile);
    

    In JavaScript:

    var text = Windows.Storage.FileIO.readTextAsync(storageFile).then(file => do_stuff(file))