Search code examples
c#wcfconfigurationwindows-xpspecial-folders

How to set config output to special folder (LocalApplicationData)?


Is there a way to set my app.config for my WCF service so that it outputs to the LocalApplicationData folder without having to hardcode anything?

%LOCALAPPDATA% does not work in XP, and I need to support XP

I have found that shell:Local AppData works, but I am not sure how to put this in an app.config

The next closest I can find is %APPDATA%, but I do not believe this is not the same as LocalApplicationData

Worst case, I can (but would prefer not to) use code to do this (using the SpecialFolders directly), but I am not sure how to set this while keeping the rest of the settings configurable?


Solution

  • I don't think there's a way to get the information you want using only built-in environment variables. The information is inconsistent from Windows XP to Windows Vista/7, so I think your best option is to update your config file during installation where you can determine the OS and access other Windows APIs.