title: C# loop through app.config but only use keys like "service"
body: <p>I'm looping through a txt file currently to get server names and check a specific services status and start it if stopped. This works perfectly with my service names stored in my app.config.
  What I want to do is also store my file path, file name, timeout, and any other keys I want to put in the app.config down the road. 
  My issue is when I loop through the app.config currently I only have service names which works perfectly. If I add the other keys that I want to add I obviously will get "Service Not Found". 
  How do I only pick keys that are "like" "service". I'm naming the keys "service1", 2, 3, etc. </p>
  
  <pre><code>foreach (string key in ConfigurationManager.AppSettings)
  {
      string value = ConfigurationManager.AppSettings[key];
  
      // Create an instance of StreamReader to read from a file.
      // The using statement also closes the StreamReader.
      using (StreamReader sr = new StreamReader(txtFilePath + txtFile))
      {
          String line;
          // Read and display lines from the file until the end
          // of the file is reached.
          while ((line = sr.ReadLine()) != null)
          {
              Console.WriteLine(line);
  
              // Check for lines with semi-colon. If semi-colon at
              // line start skip it
              if (line.StartsWith(";"))
              {
                  continue;
              }
              else
              {
                  ServiceController sc = new ServiceController(value, line);
  
                  //Create new timeout module.
                  TimeSpan timeout = new TimeSpan();
  
                  //Write current service status to console.
                  Console.WriteLine(
                      "The " + value + " service status is currently set to {0}",
                      sc.Status.ToString()
                  );
  </code></pre>