If the licensing is per user, store it in the %APPDATA%
directory. If it is a per computer license, store it in the %PROGRAMDATA%
directory or the program's installation directory.
%APPDATA%
is a shell variable (you can view them by typing set
in a command window) that points the directory where the current user's application data should be stored. It is often something like C:\Users\MyUser\AppData\Roaming
. When specifying a path for opening a file, it is possible to use the %APPDATA%
variable directly, e.g. %APPDATA%\MyCompany\LicenseFile.dat
. As @cdhowie points out in his comment, it is better to use the .NET Environment.GetFolderPath()
function than using the environment variables.
%PROGRAMDATA%
works the same way, but maps to a directory that is common for all users on the system.