I just had this problem. In the end, I just put the resulting stream in XmlReader, and then in XDocument.Load.
Your code will be
StreamResouceInfo sri = Application.GetResourceStream(new System.Uri("z.xml", UriKind.Relative));
if (null != sri)
{
XmlReader rdr = new XmlReader.Create(sri.Stream);
XDocument xDoc = XDocument.Load(rdr);
}
In my case, I used a call to WebClient.DownloadStringAsync, so it was a little different
void getCacheData_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
StringReader stream = new StringReader(e.Result);
XmlReader reader = XmlReader.Create(stream);
XDocument doc = new XDocument.Load(reader);
}
}
source
share