Answered by:
saving data to a file in metro style apps

Question
-
Hi,
I have code regarding writing data to an xml file .
addTask: function (task) {
var packaged = Windows.ApplicationModel.Package.current;
var installedLocation = packaged.installedLocation;installedLocation.createFileAsync("\data\\mydata.xml", Windows.Storage.CreationCollisionOption.replaceExisting).then(function (dataFile) {
xml.XmlDocument.loadFromFileAsync(dataFile).then(function (xmldoc) {
var taskNode = xmldoc.createElement("Task");
var parentnode = xmldoc.selectSingleNode("PM");
//===insertion goes here ==============taskNode.appendChild(xmldoc.createElement("TaskID")).innerText = new Date().getTime();
taskNode.appendChild(xmldoc.createElement("Title")).innerText = task.title;
parentnode.appendChild(taskNode);xmldoc.saveToFileAsync(dataFile).done(function () {});
});});
return true;
}which worked well in VS 2011.
but not working in VS 12 . throwing error "ACCESS IS DENIED".
can anyone help me , whats the issue ??
Monday, July 23, 2012 1:04 PM
Answers
-
Sure!
Just use the local folder like in this documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localfolder.aspx
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, July 23, 2012 6:58 PM
- Marked as answer by AKwin Tuesday, July 24, 2012 4:51 PM
Monday, July 23, 2012 6:58 PMModerator
All replies
-
Change your code to write to your .local folder and no the package install location.
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, July 23, 2012 3:02 PM
Monday, July 23, 2012 3:01 PMModerator -
Change your code to write to your .local folder and no the package install location.
-Jeff
Jeff Sanders (MSFT)
Hi jpsanders,
can you provide sample code snippet of the same you described above ..
thanks in advance .Monday, July 23, 2012 4:21 PM -
Sure!
Just use the local folder like in this documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localfolder.aspx
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, July 23, 2012 6:58 PM
- Marked as answer by AKwin Tuesday, July 24, 2012 4:51 PM
Monday, July 23, 2012 6:58 PMModerator -
Sure!
Just use the local folder like in this documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localfolder.aspx
-Jeff
Jeff Sanders (MSFT)
Tuesday, July 24, 2012 4:51 PM