Silverlight runs with elevated permissions by default(simply saying in sandbox), it means
var lines = File.ReadLines(fileStream);
wil not work, for 2 reasons:
- parameter should be string path, not a stream in silverlight api, at least.
- File.ReadLines will not work, because it works only for trusted applications.
based on above, your issue can be solved by following code:
OpenFileDialog opendialog = new OpenFileDialog();
if (opendialog.ShowDialog() == true)
{
string text = string.Empty;
using (StreamReader reader = opendialog.File.OpenText())
{
text = reader.ReadToEnd();
}
// do stuff here
}
or another options provided by msdn : http://msdn.microsoft.com/en-us/library/cc221415(v=vs.95).aspx