Answered by:

"Windows.Storage.FileIO.readTextAsync(sampleFile).done" never gets called

Question

I am following a sample about reading a text file from Storage and I am able to have the sampleFile variable correctly assigned to the wanted file (code not displayed here). When it comes to reading the file content the "done" method is never called. In
the example here below I can see "A" and "B" but not "C". I see also "D" that is issued after the scenario2ReadText call has returned (code not displayed here).

Answers

There is a problem with using document.write() in your scenario. I have not had time to study in detail but here is a modified version of your code which removes/replaces the document.write() with console.log() and calls to a "displayStatus" function
that replaces the innerHTML of a div, as in:

All replies

OK. Here is a sample that works for me. It displays the text of a file and an error message if the file is not found.

As written, the routine selects a named file in the documents folder. You must set the manifest capabilities and declarations for this to work. You can replace the Windows.Storage.KnownFolders… line with the code that has been commented out and
use the FilePicker to select the file. In this case, you don't have to set the manifest.

I set the debugger to throw Javascript exceptions but they are not thrown when expected to, that is when I cannot see "B" and so on. What else have I to set to see the exceptions or what's going wrong there?

Edit: I have two functions that call each other and the call happens just inside the functions passed in "done" of getFileAsync and readTextAsync , could it be the reason for my app not working?

There is a problem with using document.write() in your scenario. I have not had time to study in detail but here is a modified version of your code which removes/replaces the document.write() with console.log() and calls to a "displayStatus" function
that replaces the innerHTML of a div, as in: