What is the best way to save data locally to a text file?

In NSBasic, I see no direct way to just save some textual data to the hard drive on a desktop computer. I know NSBasic was made for app design, but isn’t there a direct way to just save data to a file on a local desktop machine?

I’ve looked at all the docs and the closest thing I have found is using AJAX with a server - I don’t want or need to GET or POST data just yet and will NOT be using any database files.


AppStudio is based on Web technology and runs in a browser instance. One of the security features of browsers is that the pages or apps you run should not be able to mess up your computer.

That’s why they don’t allow the creation of files - you can imagine the mischief which would be possible.

Can you explain more about what you’re trying to accomplish?

I really can’t explain much in a public forum, but I need to somehow save this data either to my local computer or encrypted here in code that cannot be intercepted and then sent to a server. I don’t care if encrypted code is intercepted en route because it’s already unreadable.


So you don’t actually need to save the data in a file - you just need to save the data somehow.

Have a look at localStorage:

If you only need to save your data as a text file, this works in Chrome. Does not work in Safari.

function saveContent(fileContents, fileName)  //Chrome only
       var link = document.createElement('a');
       link.download = fileName;
       link.href = 'data:,' + fileContents;