Page 1 of 1

where to write application data

PostPosted: Mon Apr 02, 2012 8:17 am
by cp4w
hello,

What would be the best way to set up a Neobook application.

It would seem that if the application would want to write and read data it would use the[pubdir] variable to write and read from the folder is executing from.

But correct me if I am wrong, that could cause problems because the user would have to be an administrator to write to the program files folder.

Wouldn't it be better to somehow write to a folder in "programdata".
and if so, is there a variable to support this?

how is this being handled?

PostPosted: Mon Apr 02, 2012 10:33 am
by Neosoft Support
Probably the best option would be to create a folder for your app under the user's documents folder. In NeoBook the location of the user's documents folder is stored in the global variable [MyDocuments].

PostPosted: Mon Apr 02, 2012 2:12 pm
by dec
Hi,

I think the "User documents" can be good too, however, if you need the path to others system directories which can be used too, for example, the "App Data" directory, remember my npInfo plugin allow you to know this system paths. Take a look at their "Folders.pub" sample if you like.

Image

PostPosted: Tue Apr 03, 2012 8:48 am
by cp4w
I am really surprised that this is not a more burning issue for most developers.

Am I missing something? Won't applications that write to the program files folder fail if the user is not administrator?

The type of data really does not belong in the my documents folder of the user and I think David's idea with his plug-in makes sense.

PostPosted: Tue Apr 03, 2012 9:43 am
by Gaev
Steven:

This discussion came up as soon as Vista hit production ... since then, the easiest (safest) solution has been to use the user's My Documents folder.

PostPosted: Tue Apr 03, 2012 9:59 am
by dec
Hi,

I'am not an expert on the Windows directories structure, but, maybe we are wrong if put files on the "User Documents" if such files are not created or maintained by the user, in other words, if we use this folder only because is writable.

For specific application data we can use the "Application Data" folder, and let the "User Documents" folder for files created and/or maintained by the user. Remember the user have an "Application Data" folder under their directory, and the "Application Data" is writable too.

Zarko Gajic wrote:You should not store application-specific data (such as temporary files, user preferences, application configuration files, and so on) in the My Documents folder. Instead, use an application-specific file that is located in a valid Application Data folder.


Store User and Application Data in the Correct Location

PostPosted: Tue Apr 03, 2012 10:56 am
by Neosoft Support
I think if the data is something that you want the user to be able to look at or backup then it should be in the documents folder. If the data is intended for your app's use only then it should be in the app data folder. Configuration settings should be stored in the registry.

Re: where to write application data

PostPosted: Thu Dec 04, 2014 8:03 am
by fkapnist
cp4w wrote:hello,

What would be the best way to set up a Neobook application.

It would seem that if the application would want to write and read data it would use the[pubdir] variable to write and read from the folder is executing from.

But correct me if I am wrong, that could cause problems because the user would have to be an administrator to write to the program files folder.

Wouldn't it be better to somehow write to a folder in "programdata".
and if so, is there a variable to support this?

how is this being handled?


If you try to write directly to a Program Files folder (or Program Files x86 folder) where your PubDir might be stored, you may get an "access denied" error (and your program won't work). The Windows Temp folder should be used to write and read temporary files. The example below writes to the Windows Temp folder and then reads back the file. It sets the Windows Temp folder as the current directory and uses DOS to write a file (test.txt) of the directory to the Windows Temp folder.

Code: Select all
SetVar "[CurrentDir]" "[TempDir]"
DOSCommand "dir" "> %~p0test.txt" "Normal"
TextWindow "" "-1" "-1" "450" "500" "%~p0test.txt" "Wordwrap"


Notice the %~p0 before the filename. It is the path to the new file we just wrote.
Windows uses two directories: one that contains the program, and one that contains the file to write or read to.
In fact, you can be in a third directory and call a program from one directory to write or read to another directory.
Of course you will normally use the Neobook [FileWrite] or [ExtractFile] actions. For example:

Code: Select all
FileWrite "[TempDir]test.txt" "All" "Some Text"
TextWindow "" "-1" "-1" "450" "500" "[TempDir]test.txt" "Wordwrap"


:arrow:
.