Proper settings file creation for Windows 7, Vista and XP
After installing one of my .Net apps on a Windows 7 machine I keep getting an error that my application does not have permission to save a settings file to the application folder under the program files folder. I'开发者_StackOverflow社区m aware it's possible to elevate to administrator privileges or whatever but I'd like to avoid this. I know Windows 7 and Vista have a particular location where they would like you to save settings files but I'm unsure of how to determine this location in .Net. Could anyone offer some assistance or suggestions? Thanks!
You can use the Environment.SpecialFolder enumeration to return the various 'special' directories on the user's system. You can use these as the parameters to the Environment.GetFolderPath method.
You're looking for the Environment.GetFolderPath
method, and its ApplicationData
parameter.
精彩评论