As above, how do I get the AppData folder in Windows using C?
I know that for C# you use Environment.SpecialFolder.ApplicationData
What is the AppData folder? AppData is a hidden folder located in C:\Users\<username>\AppData. The AppData folder contains custom settings and other information needed by applications. For example, you might find the following in your AppData folder: Web browser bookmarks and cache.
Normally, you will not find the AppData folder in your User Profile page because it is hidden by default. We will change the hidden settings and then access the file location. Make sure that you are logged in as an administrator.
Search for "Run" in the windows search as shown below, or press the Windows + R button to open the Run App. In the run app text box, enter "%AppData%" and click OK. Windows will directly open up the Roaming folder which is inside the AppData folder.
Use SHGetSpecialFolderPath with a CSIDL set to the desired folder (probably CSIDL_APPDATA or CSIDL_LOCAL_APPDATA).
You can also use the newer SHGetFolderPath() and SHGetKnownFolderPath() functions. There's also SHGetKnownFolderIDList() and if you like COM there's IKnownFolder::GetPath().
If I recall correctly it should just be
#include <stdlib.h>
getenv("APPDATA");
Edit: Just double-checked, works fine!
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