Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Okay, so the issue here is one of <code>Task.Run</code> and the way it handles <code>async delegates</code>. Basically, when you say:</p> <pre><code>Task.Run(async () =&gt; ...) </code></pre> <p>What it's returning to you is not the plain-jane <code>Task</code> you are expecting it to. It's returning that task <em>wrapped in another task</em>, i.e., a Task. So in order to get the task out that you're looking for (the one that retrieves the StorageFolder), you need to <code>await</code> the outer task. You can do this simply by changing when you add it to the <code>tasks</code> list:</p> <pre><code>tasks.Add(await task); </code></pre> <p>Now, there is a second issue. You're doing a bunch of reading from the same folder possibly all at the same time. This may cause some <code>AccessExceptions</code>. It may also not. I would just be careful when doing this.</p> <p>I have had problems doing file read/write in unit tests in WinRT. Luckily, I am using Mvvm (through Mvvm Light) and have wrapped my local storage accessing inside of a <code>Controller</code>. What this has allowed me to do is to write a <code>LocalStorageController</code> just for Unit testing that allows me to do all of my IO to a file system in memory (basically a simple <code>Dictionary&lt;string, byte[]&gt;</code>). This does make testing complex file trees a bit more difficult, but you could also use a different data structure (such as an actual <code>Tree</code>) to model your file system.</p> <p>Anyway, I hope this helps. I apologize that it was so long after you asked it, though. Happy coding!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload