In a C# Winforms-App I have several user settings stored.
Is there an easy way to clear those setting开发者_开发百科s each time I start debugging the project from Visual Studio 2008?
Otherwise it always starts up with the settings from the last debug-session.
Had the same question and found an answer here: https://stackoverflow.com/a/2117359/488794
Properties.Settings.Default.Reset()
You can use this following statement to only reset if you're debugging:
if(Debugger.IsAttached)
Settings.Default.Reset();
tested VS2012 .Net 4.0 (Reference)
Add a pre-build action to delete:
%USERPROFILE%\Local Settings\Application Data\[AppName]\...\[Version]\user.config
or if your version number changes alot just delete
%USERPROFILE%\Local Settings\Application Data\[AppName]\
Adding to the above answers, here a copy-paste solution that works for most settings:
rmdir /q /s %localappdata%\[company name]\[AppName]
Note that for most cases it's best to delete everything under %localappdata%[company name]. Check the app data stored there and choose what's best for you.
Run->Type "appdata"
Navigate to Local->/
Delete all files related to the project
Here are two possible ways to do it:
use either the pre build or post build event command line, you put delete commands and such in there or run a batch file or script
have a play with the Start Action options of the start up project, you can specify an external program with command line arguments to be run first
Based on other answers: just search on C:
or C:\Users\<YourUser>
for user.config
and delete or rename that file.
精彩评论