title: Copying App Package Folder To Isolated Storage For Windows Store App
body: <p>I am trying to copy the app package folder to Isolated Storage. This what I've come with. Im getting a javascript error cannot create file which already exists. Im having trouble traversing through the subfolders.</p>
  
  <pre><code>    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);
                              });
                          });
                      });
                  });
              });
          });
      }
  }
  </code></pre>