Visual Studio: reset user settings when debugging

前端 未结 6 922
深忆病人
深忆病人 2020-12-24 07:29

In a C# Winforms-App I have several user settings stored.

Is there an easy way to clear those settings each time I start debugging the project from Visual Studio 200

相关标签:
6条回答
  • 2020-12-24 07:47

    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.

    0 讨论(0)
  • 2020-12-24 07:48

    Based on other answers: just search on C: or C:\Users\<YourUser> for user.config and delete or rename that file.

    0 讨论(0)
  • 2020-12-24 07:53

    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)

    0 讨论(0)
  • 2020-12-24 07:55

    Run->Type "appdata"

    Navigate to Local->/

    Delete all files related to the project

    0 讨论(0)
  • 2020-12-24 07:57

    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

    0 讨论(0)
  • 2020-12-24 08:01

    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]\

    0 讨论(0)
提交回复
热议问题