private void LoadBackups()
 {
     LstBackupItems.Items.Clear();
     files = Directory.GetFiles(MainPage.Dir, "*.json");
     if (files.Length > 0)
     {
         foreach (string file in files)
         {
             string     fileName = file.Substring(file.LastIndexOf("\\") + 1);
             BackupData data     = new BackupData(fileName, file);
             dataEntries.Add(data);
             LstBackupItems.Items.Add(data);
         }
     }
 }
        private void LstBackupItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LstBackupItems.SelectedIndex == -1)
            {
                return;
            }

            searchIndex = LstBackupItems.SelectedIndex;
            BackupData         backup = dataEntries[searchIndex];
            List <ProgramData> data   = File.ReadAllLines(backup.Location).Select(line => JsonConvert.DeserializeObject <ProgramData>(line)).ToList();

            LstPreviewArea.Items.Clear();
            foreach (ProgramData prog in data)
            {
                LstPreviewArea.Items.Add(prog);
            }
        }
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (!CheckForSelection(searchIndex))
            {
                return;
            }

            string choice = Interaction.InputBox($"Confirm loading the entry at location {LstBackupItems.SelectedIndex + 1}?" +
                                                 "\n\nType Y to continue, anything else to exit" +
                                                 "\n\nPress X or Cancel to exit as well", "Load Entry?");

            if (choice.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                BackupData data = dataEntries[searchIndex];
                mainRef.LoadTempFile(data.Location);
                if (!mainRef.TStrpMnuItmDisableMsg.Checked)
                {
                    _ = MessageBox.Show("The entry has now been loaded in the main program!", "Backup Loaded Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (!CheckForSelection(searchIndex))
            {
                return;
            }

            string choice = Interaction.InputBox($"Confirm deleting the entry at location {LstBackupItems.SelectedIndex + 1}?" +
                                                 "\n\nType Y to continue, anything else to exit" +
                                                 "\n\nPress X or Cancel to exit as well", "Delete Entry?");

            if (choice.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                LoadBackups();
                LstBackupItems.Items.RemoveAt(searchIndex);
                BackupData data = dataEntries[searchIndex];
                File.Delete(data.Location);
                dataEntries.RemoveAt(searchIndex);
                if (!mainRef.TStrpMnuItmDisableMsg.Checked)
                {
                    _ = MessageBox.Show("The entry has now been deleted!", "Backup Delete Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }