I’ve been programming in .Net for many years now, but this one threw me off just because I was treating the WinRT api differently to standard .Net classes.
I was opening streams, writing to a file, calling .FlushAsync(), then later trying to open the same file again. I would continuously get an UnauthorizedAccessException. The answer was a simple “you forgot to dispose of the stream”, yes it is obvious in hindsight.
The solution is to simply call .Dispose() on your stream once you are finished with it, or surround it with a using statement.