Friday, September 25, 2009

Reading file from local system in Silverlight application

OpenFileDialog class will help us to read the one or more files from local system. The
following code snippet will help us to read the file from local machine.
 

OpenFileDialog file = new OpenFileDialog();
file.Filter = "Text files (*.txt)|*.txt|All Files(*.*)|*.*";

if (file.ShowDialog() == true)
{
     using (StreamReader reader = file.File.OpenText())
     {
          this.txtFileContent.Text = reader.ReadToEnd();
          reader.Close();
     }
}

Post a Comment