Skip to main content

Preserving Files & Settings

Applies to
Windows
MacOS
Linux

Your application binary files get completely replaced during updates, so you should not store important files in the same directory as your application binary files.

Application Settings

If you want to create settings that persist through updates, but are erased when the app is uninstalled, on Windows you should store them one level up (..\) outside of the current dir.

If you want to create files which persist even if the app is uninstalled (eg. important user settings) then you should store them in %AppData%\{packId} (that's the roaming app data, not local app data where the app lives).

Sentry / Crashpad / Error Reporting

Many error crash handling utilities will store error/crash reports to the application directory by default, and will upload them as a report the next time the application starts.

You need to ensure any of these libraries can be configured with a database / storage directory outside of the current application directory somewhere. On Windows, you just need to be outside the %LocalAppData%\{packId}\current directory. So you could use ..\ (this is the same as %LocalAppData%\{packId}).

Non-Windows

For other non-Windows operating systems, you should search online to find best practices about where to store settings/log files for installed apps. The recommended location is OS / distro specific, and might be in /var or somewhere in user home ~ (eg. ~/Library/Application Support on MacOS).

Finding app paths at runtime

Rather than hardcoding paths, you can ask Velopack where things live. After VelopackApp.Build().Run() has executed, VelopackLocator.Current (an IVelopackLocator) exposes:

  • RootAppDir — the application's root directory (on Windows, the {packId} folder).
  • AppContentDir — where the versioned application files live (the current folder on Windows).
  • PackagesDir — where downloaded .nupkg packages are kept.
  • AppTempDir — the temporary/working directory for this app.
  • CurrentlyInstalledVersion, Channel, and IsPortable — metadata about the install.

Using these means your "store settings one level up from the app" logic keeps working even if the install layout differs across platforms. Anything you store outside the install/RootAppDir will survive an uninstall — see Uninstalling for exactly what gets removed.