Created
April 24, 2013 06:53
-
-
Save axrwkr/5450146 to your computer and use it in GitHub Desktop.
Save a value in between exe invocations via a user setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using SaveCount.Properties; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace SaveCount | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var oldCount = Settings.Default.Count; | |
Console.WriteLine("The old count is: {0}", oldCount); | |
var newCount = Environment.TickCount; | |
Console.WriteLine("The new count is: {0}", newCount); | |
Settings.Default.Count = newCount; | |
Settings.Default.Save(); | |
} | |
} | |
} | |
// Visual studio generated code... | |
namespace SaveCount.Properties { | |
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] | |
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { | |
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); | |
public static Settings Default { | |
get { | |
return defaultInstance; | |
} | |
} | |
[global::System.Configuration.UserScopedSettingAttribute()] | |
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | |
[global::System.Configuration.DefaultSettingValueAttribute("0")] | |
public int Count { | |
get { | |
return ((int)(this["Count"])); | |
} | |
set { | |
this["Count"] = value; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment