I am trying to write these 3 arrays arrb,arr,arrc to a file as json object which i will read later but when i am calling save() function it throws an invalid pointer exception in this line of code-
Windows.Storage.FileIO.writeTextAsync(sampleFile, str1.toString() + "" + str2.toString() + "" + str3.toString()).then(function () {
// Add code to do something after the text is written to the file
});
I tried it without .toString() but not worked but when I tried writing simple text in file it works perfectly. I got these codes from msdn website and I am trying use these in my application but I am not able to overcome this exception here so please help
me how I can solve this issue. Below is my complete code:
<script type="text/javascript">
var sampleFile;
var arrb =[1, 2, 3, 4, 5, 6, 7, 8, 9];
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var arrr =[1, 2, 3, 4, 5, 6, 7, 8, 9];
var str1="a", str2="d", str3="c";
str1 = JSON.stringify(arr);
str2 = JSON.stringify(arrb);
str3 = JSON.stringify(arrr);
function save() {
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("savegame.txt",
Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
sampleFile = file;
});
Windows.Storage.FileIO.writeTextAsync(sampleFile, str1.toString() + "" + str2.toString() + "" + str3.toString()).then(function () {
// Add code to do something after the text is written to the file
});
}
</script>
</head>
<body>
<input type="button" value="save" onclick="save();" />
</body>