private void WriteStartupJobs(JobDetails jd, bool isSelected) { lock (s_lock) { ArrayList startupJobs = (ArrayList)ConfigurationManager.GetSection("StartupJobs"); try { if (isSelected) { using (StreamWriter sw = new StreamWriter(globalConfig.UserDefinedStartupJobsFilepath, true)) { sw.WriteLine(jd.Name); log.InfoFormat("Wrote {0} to user defined statrtup job file", jd.Name); } } else { if (File.Exists(globalConfig.UserDefinedStartupJobsFilepath)) { ArrayList tar = new ArrayList(); using (StreamReader sr = new StreamReader(globalConfig.UserDefinedStartupJobsFilepath)) { string record = string.Empty; while ((record = sr.ReadLine()) != null) { JobDetails _jd = new JobDetails(); _jd.Name = record; _jd.ReferencePath = record; tar.Add(_jd); } } File.Delete(globalConfig.UserDefinedStartupJobsFilepath); using (StreamWriter sw = new StreamWriter(globalConfig.UserDefinedStartupJobsFilepath)) { foreach (JobDetails _jd in tar) { if (!_jd.Equals(jd)) sw.WriteLine(_jd.Name); } } } } } catch (Exception ex) { log.Error(ex); } } }