I'm quite astounded by the apparent complexity of this seemingly simple task. I know that I have to use the StorageFile
class, and I've found this example, but I just want to read one single file, to which I know the path, and read it's data as text into a string.
From what I've been able to gather, to read a file with StorageFile
, I have to go through a bunch of interfaces; IAsyncOperation<StorageFile>
and IAsyncOperationCompletedHandler
.
There must be a better (simpler) way. Something like:
using (StorageFile sf = StorageFile.OpenAsync("myFile.txt"))
{
string line = sf.ReadLine();
}
Obviously this doesn't work, but maybe I've missed something, or someone could explain to me how to read a file in a different way?