locked
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

All replies