How do I get %LocalAppData%
in C#?
To open the AppData folder on Windows 10, 8 & 7: Open File Explorer/Windows Explorer. Type %AppData% into the address bar and hit enter. Navigate to the required folder (Roaming or Local)
The AppData folder includes application settings, files, and data unique to the applications on your Windows PC. The folder is hidden by default in Windows File Explorer and has three hidden sub-folders: Local, LocalLow, and Roaming. You won't use this folder very often, but this is where your important files reside.
Run a command shell (start/Run, then "cmd") and type "set". This will list all the environmental variables available. Having said that, USERPROFILE is perfectly valid. There's also APPDATA and LOCALAPPDATA.
If you would like to use an enumeration, try the following:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Using this technique, you can also find all other Window's file paths (i.e Program Files, My Documents, etc).
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