I'm having a little problem with my program...
I have to create a file with the application data, but I don't know how to access the %USER%
or %APPDATA%
directories...
I've tried to use the application folder, but if I install the application in D:\Program Files\(Organization)\(APPName)
I cannot write new files in this directory, I can just read or modify if I don't have admin privileges...
So, the question is: How to access the %USER% folder or Get ADMIN privileges with the application... PS.: I'm using VCL in C++ Builder
You can open it from the Start menu (Windows System → File Explorer). Or, press the keyboard shortcut Windows key + E (hold down the Windows key and press E). Click in the location bar. Type %USERPROFILE% and press Enter .
Users folder coming with C drive is set by default when installing the Windows operating system. The folder contains multiple sub-folders which are used to keep some frequently used data, such as users profile, contacts, favorites, downloads, music, documents, videos, games, etc.
Right-click an empty area on the navigation panel in File Explorer. From the context menu, select the 'Show all folders' and your user profile will be added as a location in the navigation bar. What is this? Each time you open File Explorer, you will be able to quickly access it from the navigation panel.
The root (administrative) user is the only user who has its home directory in a different location by default. The path of the root user is '/root/', where it has control under all the directories and files.
Assuming this is a pure Windows question, you should use SHGetSpecialFolderPath
.
CSIDL_PROFILE
to get the equivalent of %USERPROFILE%
.CSIDL_APPDATA
to get the equivalent of %APPDATA%
.Note that the documentations for the CSIDL based functions are a little scary in that they talk about function not being supported or deprecated. Instead they urge you to use SHGetKnownFolderPath
. That's fine if your program never needs to run on XP. If that's the case, go ahead and use SHGetKnownFolderPath
. Otherwise, use the CSIDL based options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With