private void attachControllerToId(String baseControllerFile, UInt16 attachmentId)
        {
            // Set attachment ID to chosen base controller
            ObjectTable baseTable = new ObjectTable(baseControllerFile);
            ObjectEntry entry = (ObjectEntry)baseTable.entries[0];

            if (entry.addAttachment(attachmentId))
            {
                File.Copy(baseControllerFile, baseControllerFile + ".bak", true);
                baseTable.writeToFile(baseControllerFile);
                MessageBoxEx.Show(this, "Success!!");
            }
            else
            {
                MessageBoxEx.Show(this, "You have surpassed the limit of attachments to add to this controller");
            }
        }
        private void swapSlotsCharacterSwapButton_Click(object sender, EventArgs e)
        {
            String controllerPath = swapSlotsCharacterControllerTextBox.Text;
            if (controllerPath == null || controllerPath.Equals(""))
            {
                MessageBoxEx.Show(this, "You have to select a controller!");
                return;
            }

            if (swapSlotsCharacterSlotComboBox.SelectedItem == null)
            {
                MessageBoxEx.Show(this, "Select valid values in the highlighted fields");
                return;
            }

            // After validating the data, swap slots!
            try
            {
                // Test if the given file is a valid controller
                ObjectTable table = new ObjectTable(controllerPath);
                int dlcSlotNumber = (int)swapSlotsCharacterSlotComboBox.SelectedIndex + 1;
                UInt16 dlcSlotId = (UInt16)swapSlotsCharacterSlotComboBox.SelectedValue;

                ObjectEntry entry = (ObjectEntry)table.entries[0];
                // Change DLC id to one valid with the slot if needed
                if (swapSlotsCharacterChangeIdCheckBox.Checked)
                {
                    entry.id = dlcSlotId;
                }
                entry.objectEntrySlot = (byte)dlcSlotNumber;
                // Delete old file and create a new one
                String parentPath = Path.GetDirectoryName(controllerPath);
                File.Delete(controllerPath);
                String objectTableHashFileName = Hasher.hash("dlc/obj/dlc_" + dlcSlotNumber.ToString("d3") + "oe.bin") + ".edat";
                table.writeToFile(System.IO.Path.Combine(parentPath, objectTableHashFileName));
                MessageBoxEx.Show(this, "Success!");

            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, "Select a valid controller");
                Logger.Log("MainFormSwapSlotsUserControl", ex);
                return;
            }
        }