Which directory should I choose to store data files created in my application?

Windows specific forum
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: Which directory should I choose to store data files created in my application?

Post by AZJIO »

RegularExpression adds 150kb to your program. You can use the StringField function.

Code: Select all

StringField(StringToCheck , wordnum, "-")
You can also get the path this way

Code: Select all

; https://www.purebasic.fr/english/viewtopic.php?f=12&t=56204
XIncludeFile "Registry.pbi"
UseModule Registry
Debug ReadValue(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "AppData")
Debug ReadValue(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "AppData")
But you need to fix Registry.pbi. Look here in the "Include" folder
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Which directory should I choose to store data files created in my application?

Post by Marc56us »

Program data should be placed in %LocalAppData%.

If the program is to be used on a network (from another machine or even locally), program data should be put in %AppData% (which corresponds to Roaming (as for telephones from abroad)

User data in Home Dir ("Documents")

Code: Select all

Debug "Program Datas (Roaming and local) : " + GetUserDirectory(#PB_Directory_ProgramData)
Debug "Program Local Datas               : " + GetEnvironmentVariable("LOCALAPPDATA")
Debug "User documents                    : " + GetUserDirectory(#PB_Directory_Documents)
To find out the variable mapping (GetEnvironmentVariable("?")), type SET in the console

But of course you can do as you please and let the user take care of the backups... :mrgreen:

:wink:
Jan2004
Enthusiast
Enthusiast
Posts: 163
Joined: Fri Jan 07, 2005 7:17 pm

Re: Which directory should I choose to store data files created in my application?

Post by Jan2004 »

Information about %LocalAppData% I found at https://answers.microsoft.com/en-us/win ... 0d4a2f489a

"Program data is a protected system folder which contains all data and configuration of the programs that your PC has, the purpose is keeping safe that data and avoid possible risks to delete it. ProgramData focuses on storing all the generic information of the applications, information that all users can access by default. For example Antivirus will save your database and settings in this directory, this folder can be found in the dirve C:\ or you can enter %programdata% in the address bar of the Windows Explorer."

Now I need some time to carefully analyze the given codes and to check the operations on different versions of Windows - I have XP, 7, 10.
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Which directory should I choose to store data files created in my application?

Post by mk-soft »

Perhaps with this PathHelper ... All OS

Module PathHelper
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Jan2004
Enthusiast
Enthusiast
Posts: 163
Joined: Fri Jan 07, 2005 7:17 pm

Re: Which directory should I choose to store data files created in my application?

Post by Jan2004 »

mk-soft, I included your code for in-depth analysis. In connection with the issue I raised in the topic, I now have some material to analyze.
Post Reply