Nejdi Kroi
Nejdi Kroi

Reputation: 612

StreamReader in Windows 10 Universal App

I am trying to read from a XML file in Windows 10 Universal App. StreamReader only takes Stream as argument. I used to do this with the file path in WinForms, WPF or MVC but I don't know how to do it in Windows 10 universal app.

TextReader reader = new StreamReader(@"C:\Users\User\documents\visual studio 2015\Projects\SQLiteApp\SQLiteApp\SomeFile.xml");

enter image description here

Upvotes: 0

Views: 4996

Answers (1)

David Leitner
David Leitner

Reputation: 3382

Indeed, Windows 10 and the sandbox has many limitations in where you can read from/write to.

This is not a Windows 10 App "Problem", but a Windows Store App Api change. A common way to read a file in a Windows Store App is to use the StorageFile:

 StorageFile file = 
      await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///yourFile.txt");

Take a look at this post, to get more information about reading files in windows 10.

Upvotes: 4

Related Questions