How can I create a file in the directory in which my application is installed?
I’ve tried the following, and it doesn’t work. Basically I need to be able to create the file in C:\Program Files\MyAppName\ on Windows XP or C:\Program Files(x86)\MyAppName on Windows Vista and newer.
SaveStringToFile("{pf}\{#MyAppName}\Registration.txt", Serial, False);
It’s better to use the special constant {app}, in case the user chooses a different directory to install it in.
To save the file in the Application Data directory (shared by all users), use the constant
{commonappdata}instead of{app}.Note that
{app}points to “C:\Program Files\My Application\” (or wherever the user chose to install the application and depending on the OS).{commonappdata}, on the other hand, points to the root of the Application Data directory, so it’d be good idea in this case to add a directory for your app, (or company and app):For example: