title: How to change JSON save location/directory in NW.js
body: <p>I want to load a JSON file from a folder called saveFiles (in the same directory as the nw.exe file and the package.json file (manifest file)). The problem is that the program currently saves the JSON file to the <code>C:\Users\userName\AppData\Local\appName\User Data\Default folder</code>. I cannot figure out how to change the destination folder. I read that I could change it by adjusting the <code>"chromium-args": "--data-path=''</code> value in the manifest package.json file. But I do not know what value I need to use for it to work. Currently the package.json looks like this:</p>
  
  <pre><code>{
  "main": "index.html",
  "name": "appName",
  "chromium-args": "--data-path='./saveFiles/'",
  "window":
    {
        "toolbar": true,
        "width": 1600,
        "height": 900,
        "min_width": 1000,
        "min_height": 500,
        "fullscreen": true,
        "title":"App Name"
    }
  }
  </code></pre>
  
  <p>I have tried several variations to try to make it work: <code>--data-path='./saveFiles/'</code>, <code>--data-path='/saveFiles/'</code>, <code>--data-path='saveFiles/'</code>, but nothing has been successful. Is my format wrong? Should I be using something other than <code>"chromium-args": "--data-path=''"?</code> Is there a different way to change the save location/directory? I do not know how to change it to make it work.</p>
  
  <p>More information:</p>
  
  <p>When I save the JSON file, I use the following code:</p>
  
  <pre><code>var fs = require('fs');
  var path = require('path');
  function saveSettings (settings, callback) {
    var file = 'testSave.json';
    var filePath = path.join(nw.App.dataPath, file);
    fs.writeFile(filePath, settings, function (err) {
      if (err) {
        console.info("There was an error attempting to save your data.");
        console.warn(err.message);
        return;
      } else if (callback) {
        callback();
      }
    });
  }
  var mySettings = {
    color:'red',
    secondaryColor:'blue'
  }
  mySettings = JSON.stringify(mySettings);
  saveSettings(mySettings, function () {
      console.log('Settings saved');
  });
  </code></pre>
  
  <p>This works to save the file to the C:\Users\userName\AppData\Local\appName\User Data\Default folder, but I want to save it to the saveFiles folder (in the same location as the manifest file (package.JSON) and nw.exe file (which is in the same folder as the package.json)).</p>
  
  <p>The load function to load the JSON file looks like this:</p>
  
  <pre><code>function testLoadFunc(){
    path = require('path');
  
    var xmlhttp = new XMLHttpRequest();
    var url = "saveFiles/testSave.json";
  
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 &amp;&amp; this.status == 200) {
          var loadedSettings = JSON.parse(this.responseText);
          console.log('color: ' + loadedSettings.color);
        }
    };
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
  }
  testLoadFunc(); //Loads json file
  </code></pre>
  
  <p>This loads the file correctly, but I have to manually place the testSave.json file into the saveFiles folder. I want to automatically save the testSave.json into the saveFiles folder. Thus I am trying to find out how to change the save location/directory.</p>
  
  <p>An alternative option would be to figure out how to load the file from the current save location <code>C:\Users\userName\AppData\Local\appName\User Data\Default</code>, but I do not know how to do that either. The preferable option would be to just change the save location to the saveFiles folder.      </p>
  
  <p>Thank you for any help you can provide.</p>