Difference between revisions of "Application Data Storage"

From den4b Wiki
Jump to navigation Jump to search
(How to change the storage path)
m (Fixed typos)
Line 3: Line 3:
 
Applications often require a dedicated location for storing the application data, such user settings, profiles and documents.
 
Applications often require a dedicated location for storing the application data, such user settings, profiles and documents.
  
The choice of the storage location can vary wildly between different purposes, applications and operating system, but generally speaking they follow one of the two common conventions.
+
The choice of the storage location can vary wildly between different purposes, applications and operating systems, but generally speaking they follow one of the two common conventions.
  
# '''Portable versions''' – Portable applications usually do not require any system specific installation or uninstallation routines, instead, they come in a form or an archive which you can unpack anywhere you like. All (or almost all) application data is stored in the same directory as the application executable file. This makes the application folder self-contained and portable.  
+
# '''Portable versions''' – Portable applications usually do not require any system specific installation or uninstallation routines, instead, they come in a form of an archive which you can unpack anywhere you like. All (or almost all) application data is stored in the same directory as the application executable file. This makes the application folder self-contained and portable.  
 
# '''Installer versions''' – The application executable is normally installed in a system protected location (e.g. "C:\Program Files"), while the application data is stored in a separate user-accessible location dedicated by the operating system, such as the user profile directory (e.g. "C:\Users\User").
 
# '''Installer versions''' – The application executable is normally installed in a system protected location (e.g. "C:\Program Files"), while the application data is stored in a separate user-accessible location dedicated by the operating system, such as the user profile directory (e.g. "C:\Users\User").
  

Revision as of 23:16, 16 January 2021

Introduction

Applications often require a dedicated location for storing the application data, such user settings, profiles and documents.

The choice of the storage location can vary wildly between different purposes, applications and operating systems, but generally speaking they follow one of the two common conventions.

  1. Portable versions – Portable applications usually do not require any system specific installation or uninstallation routines, instead, they come in a form of an archive which you can unpack anywhere you like. All (or almost all) application data is stored in the same directory as the application executable file. This makes the application folder self-contained and portable.
  2. Installer versions – The application executable is normally installed in a system protected location (e.g. "C:\Program Files"), while the application data is stored in a separate user-accessible location dedicated by the operating system, such as the user profile directory (e.g. "C:\Users\User").

Where is my data

If you are using the installer version, your application data should be stored in the user profile directory.

Type the following path into the address bar of File Explorer:

%USERPROFILE%\Documents\den4b\

There, you should see one or more sub-folders, one per installed application.

In a standard Windows installation, for a username "UserName" and an application name "AppName", the fully resolved path should look like this:

C:\Users\UserName\Documents\den4b\AppName\

Change the storage path

You can redefine the path used for storing the application data.

Edit or create Storage.ini file in the installation folder, where the application executable file is located.

For example, if you have installed the application into:

C:\Program Files\AppName\

Then, the expected full path for Storage.ini file is:

C:\Program Files\AppName\Storage.ini

If you don't find the file or the file is empty, then the application data will stored in the same folder as the application executable file, which is the default behavior for Portable versions.

The content of Storage.ini can be either empty or contain the path to the application data. The path may also contains environment variables and predefined path tags.

By default, the Installer versions should have the following content in Storage.ini file:

#USER#

This is a path tag that stands for a vendor and application specific folder structure within the user profile directory.

You can replace the content with any valid path, but be aware that the existing application data will not be automatically migrated to the new path.

Examples of custom storage paths

Z:\Personal\Application\Settings\
%USERPROFILE%\AppName\
%APPDATA%\AppName\

See also the full list of Environment variables.

UAC and VirtualStore

Microsoft has introduced a concept of virtual storage, as a part of the User Account Control (UAC) system, for backward compatibly with legacy applications which attempt to save data in protected locations, such as "C:\Program Files". This feature was introduced in Windows Vista and is also present in later versions of Windows. For more information, see New UAC Technologies for Windows Vista.

This feature affects some older versions of den4b products, which always store user settings in the application executable folder. If the application was installed in a protected location, the actual saved content would be redirected to the so called VirtualStore location, usually without the application ever knowing the real path.

Type the following path into the address bar of File Explorer to access the root VirtualStore location:

%LOCALAPPDATA%\VirtualStore

Example of VirtualStore path

For example, if a legacy application was installed in:

C:\Program Files\AppName

And the application attempted to save a file in:

C:\Program Files\AppName\Settings.ini

The actual file would be transparently saved in:

C:\Users\UserName\AppData\Local\VirtualStore\Program Files\AppName\Settings.ini

Assuming a standard Windows installation with a username "UserName".