I have a Windows 8.1 App from which I want to write to and read from an XML file that is put in the "Assets" folder in the Application package.
I call the following method from the page constructor after the this.InitializeComponent();
line:
private async void ReadXML()
{
var uri = new System.Uri("ms-appdata:///Assets/gameInfo.xml");
StorageFile file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
XmlDocument reader = new XmlDocument();
reader.LoadXml(file.ToString());
XmlNodeList nodes = reader.DocumentElement.ChildNodes;
string attr = nodes[0].Attributes[0].InnerText;
int bestTime;
if (attr != null && int.TryParse(attr, out bestTime))
BestTime = bestTime;
}
When I navigate to the page that contains this code and it runs I get an ArgumentException thrown on the StorageFile file...
line. Here is the exception detail:
System.ArgumentException was unhandled by user code
HResult=-2147024809
Message=Value does not fall within the expected range.
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at LightsOutApp.Random4x4.<ReadXML>d__0.MoveNext()
InnerException:
Does anyone have any idea why this exception is being thrown? Thank you for any help.
I tried doing ms-app in stead of ms-appdata and it fixed that error. Thank you for your help.
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.