File location for config file to app installed to local user location
I have a WinForm app that has inside of 开发者_运维技巧the app's config file locations to find files for the app to use as it runs. However, the app will be installed locally for each user so it can't be hard coded. For Vista and Windows 7 the installer puts the app in c:\users\\Documents area. Under Windows XP it puts it in a different location. How can I write the config file to use some sort of placeholder to be filled in at runtime with the specific user's information? I am just using the default areas that Windows wants to install a per-user install but need the config file to be flexible at runtime for the specific user.
Use string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
, that will give you the users Document folder, regardless to OS they are running on.
List of special folders that can be passed in documented here.
精彩评论