使用 Visual Studio Express 在 Javascript 中编写 Windows 8 应用程序。我不确定我是否缺少链接依赖或其他东西,但我让我的游戏用户能够将他们的进度保存到文件中(至少是这样的想法)。但是,当我运行以下代码时,即使我可以在那里看到文件,文件指针似乎也是未定义的。看到我遗漏的任何东西了吗?
var myStats = new Array();
myStats[0] = myTitle;
myStats[1] = currPage;
myStats[2] = currStep;
myStats[3] = currTune;
myStats[4] = musicon;
myStats[5] = gameComplete;
var save01File = null;
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("Asave01.dat", Windows.Storage.CreationCollisionOption.replaceExisting).done(
function (file) {
save01File = file;
},
function (error) {
WinJS.log && WinJS.log(error, "sample", "error");
});
Windows.Storage.FileIO.writeLinesAsync(save01File, myStats).done(
function () {
},
function (error) {
WinJS.log && WinJS.log(error, "sample", "error");
errCount++;
});
if (errCount == 0) {
fileMenuTitle.text = "File Saved - Click Cancel";
fileMenuTitle.text = fileMenuTitle.text + "\nto Return or Select Another File to Load";
fileMenuTitle.color = "green";
}
else {
fileMenuTitle.text = "There was an error saving that file.";
fileMenuTitle.text = fileMenuTitle.text + "\nPlease Make Another Selection.";
fileMenuTitle.color = "firebrick";
}