0

I'm writing a small application that will only run on weekends and weekdays between 6pm and 9am. I intend to do this in the app.config file. I've never worked with the app.config file and I'm looking for some direction on how I would go about implementing this task

Craig Gallagher
  • 1,613
  • 6
  • 23
  • 52

1 Answers1

1

Place a time key/value pair in your app.config. Have your code check to determine if the current time is within the time parameters in the app.config.

>     >     Configuration myConfig = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
>     >         myConfig.AppSettings.Settings.Add("StartTime", "1800");
>     >         myConfig.AppSettings.Settings.Add("EndTime", "0900");
>     >         myConfig.Save(ConfigurationSaveMode.Minimal);

then have your c# code convert the current time to your desired format then check if time is greater than start time and less then end time

jpace7
  • 56
  • 1
  • 3