Silverlight 2 Beta 1 doesn't allow direct access to local files since it is a security issue (remember it is running in the context of a browser). Your best bet is to use the OpenFileDialog as per the example given by Thierry.
Once you get the stream as string from the openfiledialog, you can pass that as input to XElement/XDocument, like this -
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "XML Files (*.xml)|*.xml";
if (dlg.ShowDialog() == DialogResult.OK) {
using (StreamReader reader = dlg.SelectedFile.OpenText()) {
string xml = reader.ReadToEnd();
var xe = new XElement(xml);
}
}
Yep, a slightly roundabout way of doing things, but you could probably encapsulate the above code in a method which will simplify usage. There is no way to get past the user confirmation though (openfiledialog)
Hope this helps!
Wilfred Pinto
http://projectsilverlight.blogspot.com