Windows Application Data Catalog

With the environment variable% allusersprofile% I can get the directory where the general settings are stored. But most programs save their settings in a subfolder of "anwendungsdaten" (German, application data). Is there any way to get the direct path to this folder? The problem is that his name depends on the language. Thanks.

+4
source share
3 answers

Not sure which programming language you are using, so I will take the base Windows api. In XP, you can call SHGetFolderPath with CSIDL_COMMON_APPDATA as a parameter. Vista and 7 seem to have a new set of features that do the same, you probably want to name SHGetKnownFolderPath .

On Windows Forms, you can use the Application.UserAppDataPath property.

+3
source

I do not see a direct way to get this information directly. If nothing comes up, the only thing that comes to mind is something hacked that will probably work in 99% of cases:

  • Take %USERPROFILE%

  • Take %APPDATA%

  • Take %APPDATA% and replace %USERPROFILE% with null. "Rest" should be "/ Application Data" or "/ Anwendungsdaten" or something else

  • Take %ALLUSERSPROFILE%

  • Add the result of step 3 to it.

  • You must specify the correct localized path to the Appdata directory of the All Users profile.

Note. This has not been verified, and I have little experience in this field. But that might work.

+1
source

I don’t know about any direct way to get it, but if it’s your problem, you can grab the end of% APPDATA%, from the last '\' to the end of the line and add this to% allusersprofile%.

0
source

Source: https://habr.com/ru/post/1305132/


All Articles