Source language: Translate to:

where to write application data

General questions about NeoBook

Moderator: Neosoft Support

where to write application data

Postby cp4w » Mon Apr 02, 2012 8:17 am

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?
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY

Postby Neosoft Support » Mon Apr 02, 2012 10:33 am

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].
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby dec » Mon Apr 02, 2012 2:12 pm

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
Last edited by dec on Tue Apr 03, 2012 8:59 am, edited 1 time in total.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby cp4w » Tue Apr 03, 2012 8:48 am

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.
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY

Postby Gaev » Tue Apr 03, 2012 9:43 am

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.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dec » Tue Apr 03, 2012 9:59 am

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
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby Neosoft Support » Tue Apr 03, 2012 10:56 am

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.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: where to write application data

Postby fkapnist » Thu Dec 04, 2014 8:03 am

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:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron