In Silverlight 4 apps which run with Elevated Trust can access local files by using System.IO and related types that would otherwise be unavailable. This allows apps to access user files directly without recourse to the OpenFileDialog and SaveFileDialog classes. However, access is limited to the the MyDocuments, MyPictures,MyMusic, and MyVideos folders.
Use the local file access APIs in the same way as the desktop framework, but use the values of the System.Environment..SpecialFolder enumeration to create the paths. For example:
private void TestLocalFileAccess()
{
if (Application.Current.HasElevatedPermissions)
{
string myDocuments = Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments);
string filenamestr = "testfile.txt";
string pathstr = System.IO.Path.Combine(myDocuments, filenamestr);
if (File.Exists(pathstr))
{
string contents = File.ReadAllText(pathstr);
MessageBox.Show(contents);
}
}
}