I am building a Windows Phone 8.1 RT App which runs MP3 files in Background task .
I followed the steps in the sample code shown here : http://code.msdn.microsoft.com/windowsapps/BackgroundAudio-63bbc319
In MyPlaylistManager Project I would like to build my own Playlist from XML file.
When I try to access this XML file I am getting an exception.
An exception of type 'System.Xml.XmlException' occurred in SYSTEM.XML.NI.DLL but was not handled in user code
Additional information: An internal error has occurred.
I have added the XML file to the Project and set
Build Action : Content
Copy to Output Directory : Copy if newer
To access the file I tired below options :
XDocument xdoc = XDocument.Load("ms-appx:///XYZ.xml");
XDocument xdoc = XDocument.Load("XYZ.xml");
XDocument.Load is supported in Windows Phone 8.1 as per the documentation: http://msdn.microsoft.com/en-us/library/bb343181(v=vs.110).aspx
Any pointers on what I am doing wrong. Thanks.
I think that the problem is, because you aren't providing the correct path. Your file is in project MyPlaylistManager . Try to use:
XDocument xdoc = XDocument.Load("ms-appx:///MyPlaylistManager/Quran.xml");
// or like this:
StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"MyPlaylistManager\Quran.xml");
Also not forget to include MyPlaylistManager in references. Maybe this answer will also help a little.
EDIT - you may also try to use XDocument.Load(Stream) - then in your BackgroundTask first get the StorageFile then load XDocument using Stream got from the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.