0
我試圖將應用程序包文件夾複製到獨立存儲。這是我一起來的。我得到一個JavaScript錯誤不能創建已經存在的文件。我有困難遍歷子文件夾。將應用程序包文件夾複製到Windows Store應用程序的獨立存儲
var root = Windows.ApplicationModel.Package.current.installedLocation;
copySubDirectories(root);
function copySubDirectories(subFolder) {
currentFolder.createFolderAsync(subFolder.name).done(function (newFolder1) {
subFolder.getFilesAsync().done(function (fileList1) {
if (fileList1==null) {
subFolder.getFoldersAsync().done(function (folderList1) {
folderList1.forEach(function (subFolder2) {
currentFolder = newFolder1;
copySubDirectories(subFolder2);
});
});
return;
}
fileList1.forEach(function (subFile1) {
subFile1.copyAsync(newFolder1, subFile1.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function() {
subFolder.getFoldersAsync().done(function (folderList1) {
folderList1.forEach(function (subFolder2) {
currentFolder = newFolder1;
copySubDirectories(subFolder2);
});
});
});
});
});
});
}
}
我很好奇 - 爲什麼你要複製整個包文件夾,其中包括所有的代碼等?似乎你主要只想複製數據子文件夾,這樣你可以使用包內容作爲基礎,然後在運行時更新數據。誠然,在JS應用程序中,代碼通常並不那麼大;仍然,這裏的方法意味着你要複製啓動畫面圖像,庫等,這隻會浪費存儲空間。 – 2014-12-04 18:46:21