/// <summary> /// OnStart(): Put startup code here /// - Start threads, get inital data, etc. /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { Log("Started", true); try { if (!Initialized) { GroupCollectionObject = new GroupCollection(AppDomain.CurrentDomain.BaseDirectory + @"\FileOrganiserGroups.xml", new TaskDetail(GetTaskDetails)); Log("Loaded Groups - " + GroupCollectionObject.GroupListWithTimer.Count.ToString(), true); GroupCollectionObject.ScheduleGroups(); Initialized = true; } } catch (Exception ex) { Log("Failed To Load GroupCollectionObject [" + ex.Message + "]", true); } base.OnStart(args); }
static void Main() { GroupCollectionPath = Application.StartupPath + @"\FileOrganiserGroups.xml"; GroupCollectionObject = new GroupCollection(GroupCollectionPath); OptionsObject = new Options(Application.StartupPath + @"\FileOrganiserOptions.xml"); FileTypesObject = new FileTypes(Application.StartupPath + @"\FileTypes.txt"); FileAttributesObject = new FileAttributes(Application.StartupPath + @"\FileAttributes.txt"); FileOrganizerServiceControllerInstalled = (new List<ServiceController>(ServiceController.GetServices())).FindIndex(sO => sO.ServiceName == "File Organizer Service") != -1; if (FileOrganizerServiceControllerInstalled) FileOrganizerServiceControllerObject = new ServiceController("File Organizer Service"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainFormObject = new Main(); Application.Run(MainFormObject); }