开发者

Where should I store a license file? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Where and how should I save license related information?

I create a license file for my ap开发者_如何学编程plication in order to distribute to users. But I have no idea where should I store the license file in a user computer.

Any suggestion? thanks


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.


Storing licenses in form of encrytped registry keys can be another option. For per computer license, store the key in HKLM\Software and for per user license, store the key in HKCU\Software

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜