public void CreateTechnicModZip(Mcmod mod, string modfile)
        {
            if (mod.IsSkipping)
            {
                return;
            }
            string fileName = modfile.Substring(modfile.LastIndexOf(Globalfunctions.PathSeperator) + 1);
            string modMd5 = SqlHelper.CalculateMd5(modfile);
            _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
            # region permissions
            if (TechnicPermissions.Checked)
            {
                PermissionPolicy permissionPolicy = _ftbPermsSqLhelper.FindPermissionPolicy(mod.Modid, TechnicPublicPermissions.Checked);
                string overwritelink;
                OwnPermissions ownPermissions;
                string customPermissionText;
                switch (permissionPolicy)
                {
                    case PermissionPolicy.Open:
                        CreateTechnicPermissionInfo(mod, permissionPolicy);
                        break;
                    case PermissionPolicy.Notify:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog(mod.Name + " requires that you notify the author of inclusion." + Environment.NewLine + "Please provide proof(an imgur link) that you have done this:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink);
                                        customPermissionText = "Proof of notitification: " + overwritelink;
                                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog(mod.Name + " requires that you notify the author of inclusion." + Environment.NewLine + "Please provide proof(an imgur link) that you have done this:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        else
                        {
                            customPermissionText = "Proof of notitification: " + ownPermissions.PermissionLink;
                            CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText);
                        }
                        break;
                    case PermissionPolicy.FTB:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is FTB exclusive" + Environment.NewLine + "Please provide proof(an imgur link) of things being otherwise:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is FTB exclusive" + Environment.NewLine + "Please provide proof(an imgur link) of things being otherwise:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = "Proof of permission outside of FTB: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Request:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("This mod requires that you request permissions from the Mod Author of " + mod.Name + Environment.NewLine + "Please provide proof(an imgur link) that you have this permission:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name);
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("This mod requires that you request permissions from the Mod Author of " + mod.Name + Environment.NewLine + "Please provide proof(an imgur link) that you have this permission:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Closed:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("The FTB permissionsheet states that permissions for " + mod.Name + " is closed." + Environment.NewLine + "Please provide proof(an imgur link) that this is not the case:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, _ftbPermsSqLhelper.GetPermissionFromModId(mod.Modid).modLink);
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("The FTB permissionsheet states that permissions for " + mod.Name + " is closed." + Environment.NewLine + "Please provide proof(an imgur link) that this is not the case:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name);
                            }
                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                    case PermissionPolicy.Unknown:
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        var modLink = ownPermissions.ModLink;
                        if (!ownPermissions.HasPermission)
                        {
                            overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is unknown" + Environment.NewLine + "Please provide proof(an imgur link) of permissions:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            while (true)
                            {
                                if (overwritelink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (Uri.IsWellFormedUriString(overwritelink, UriKind.Absolute))
                                {
                                    if (overwritelink.ToLower().Contains("imgur"))
                                    {
                                        break;
                                    }
                                }
                                overwritelink = Prompt.ShowDialog("Permissions for " + mod.Name + " is unknown" + Environment.NewLine + "Please provide proof(an imgur link) of permissions:" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                            while (string.IsNullOrWhiteSpace(modLink))
                            {
                                if (modLink != null && modLink.ToLower().Equals("skip".ToLower()))
                                {
                                    mod.IsSkipping = true;
                                    return;
                                }
                                if (modLink != null && Uri.IsWellFormedUriString(modLink, UriKind.Absolute))
                                {
                                    _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                                    break;

                                }
                                modLink = Prompt.ShowDialog("Please provide a link to " + mod.Name + ":" + Environment.NewLine + "Enter \"skip\" to skip the mod.", mod.Name, true, Prompt.ModsLeftString(_totalMods, _currentMod));
                            }
                            string a = GetAuthors(mod);
                            _ownPermsSqLhelper.AddOwnModPerm(mod.Name, mod.Modid, overwritelink, modLink);
                            CreateOwnPermissionInfo(mod.Name, mod.Modid, a, overwritelink, modLink);

                        }
                        ownPermissions = _ownPermsSqLhelper.DoUserHavePermission(mod.Modid);
                        customPermissionText = GetAuthors(mod) + " has given permission as seen here: " + ownPermissions.PermissionLink;
                        CreateTechnicPermissionInfo(mod, permissionPolicy, customPermissionText, ownPermissions.ModLink);
                        break;
                }
            }
            # endregion
            if (SolderPack.Checked)
            {
                bool force = forcesolder.Checked;
                bool useSolderBool = useSolder.Checked;
                BackgroundWorker bw = new BackgroundWorker();
                _runningProcess++;
                bw.DoWork += (o, arg) =>
                {

                    var modid = mod.Modid.Contains("|")
                        ? mod.Modid.Replace("|", "+")
                            .Replace(".", string.Empty)
                            .ToLower()
                        : mod.Modid.Replace(".", string.Empty).ToLower();
                    string modversion = mod.Mcversion.ToLower() + "-" + mod.Version.ToLower();
                    if (useSolderBool && !force)
                    {
                        if (_solderSqlHandler.IsModversionOnline(modid, modversion))
                        {
                            Debug.WriteLine(modid + " is already online with version " + modversion);
                            int id = _solderSqlHandler.GetModId(modid);
                            int modVersionId = _solderSqlHandler.GetModversionId(id, modversion);
                            _solderSqlHandler.AddModversionToBuild(_buildId, modVersionId);
                            _runningProcess--;
                            return;
                        }
                    }

                    while (true)
                    {
                        if (_processesUsingModID.ContainsKey(mod.Modid))
                        {
                            Debug.WriteLine("Sleeping with id: " + mod.Modid);
                            Thread.Sleep(100);
                        }
                        else
                        {
                            _processesUsingModID.Add(mod.Modid, 1);
                            break;
                        }
                    }

                    if (!_modsSqLhelper.IsFileInSolder(modfile) || force)
                    {
                        var modDir = Path.Combine(_outputDirectory, "mods",
                            mod.Modid.Contains("|")
                                ? mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower()
                                    .Replace(Globalfunctions.PathSeperator.ToString(), string.Empty)
                                : mod.Modid.Replace(".", string.Empty)
                                    .ToLower()
                                    .Replace(Globalfunctions.PathSeperator.ToString(), string.Empty), "mods");
                        Directory.CreateDirectory(modDir);
                        if (_processesUsingFolder.ContainsKey(modDir))
                        {
                            _processesUsingFolder[modDir]++;
                        }
                        else
                        {
                            _processesUsingFolder.Add(modDir, 1);
                        }
                        string tempModFile = Path.Combine(modDir, fileName);

                        string tempFileDirectory =
                            tempModFile.Remove(tempModFile.LastIndexOf(Globalfunctions.PathSeperator));

                        Directory.CreateDirectory(tempFileDirectory);
                        File.Copy(modfile, tempModFile, true);

                        var modArchive = mod.Modid.Contains("|")
                            ? Path.Combine(_outputDirectory, "mods",
                                mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower(),
                                mod.Modid.Replace("|", "+")
                                    .Replace(".", string.Empty)
                                    .ToLower() + "-" + mod.Mcversion.ToLower() + "-" + mod.Version.ToLower() + ".zip")
                            : Path.Combine(_outputDirectory, "mods", mod.Modid.Replace(".", string.Empty).ToLower(),
                                mod.Modid.Replace(".", string.Empty).ToLower() + "-" + mod.Mcversion.ToLower() + "-" +
                                mod.Version.ToLower() + ".zip");
                        if (Globalfunctions.IsUnix())
                        {
                            Environment.CurrentDirectory = Path.Combine(_outputDirectory, "mods",
                                mod.Modid.Contains("|")
                                    ? mod.Modid.Replace("|", "+")
                                        .Replace(".", string.Empty)
                                        .ToLower()
                                    : mod.Modid.Replace(".", string.Empty).ToLower());
                            _startInfo.FileName = "zip";
                            _startInfo.Arguments = "-r \"" + modArchive + "\" \"mods\" ";
                        }
                        else
                        {
                            _startInfo.Arguments = "a -y \"" + modArchive + "\" \"" + modDir + "\" ";
                        }
                        Process process = new Process { StartInfo = _startInfo };

                        process.Start();

                        //Save mod to database
                        _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, true);

                        // Add mod info to a html file
                        CreateTableRow(mod.Name.Replace("|", "+"), modid, modversion);

                        process.WaitForExit();

                        if (useSolderBool)
                        {
                            int id = -1;
                            string archive = Path.Combine(_outputDirectory, "mods", modArchive);
                            SolderSqlHandler sqh = new SolderSqlHandler();
                            string md5Value = SqlHelper.CalculateMd5(archive).ToLower();
                            if (sqh.IsModversionOnline(modid, modversion))
                            {
                                Debug.WriteLine(string.Format("Updating mod on solder with Modid: {0} modversion: {1} md5value: {2}", modid, modversion, md5Value), doDebug.Checked);
                                sqh.UpdateModversionMd5(modid, modversion, md5Value);
                                Debug.WriteLine(string.Format("Done updating mod on solder with modid: {0}", modid));
                            }
                            else
                            {
                                id = sqh.GetModId(modid);
                                if (id == -1)
                                {
                                    sqh.AddModToSolder(modid, mod.Description, GetAuthors(mod), mod.Url,
                                        mod.Name);
                                }
                                Debug.WriteLine(string.Format("Adding mod to solder with Modid: {0} modversion: {1} md5value: {2}", modid, modversion, md5Value), doDebug.Checked);
                                sqh.AddNewModversionToSolder(modid, modversion, md5Value);
                            }
                            id = sqh.GetModId(modid);
                            int modVersionId = sqh.GetModversionId(id, modversion);
                            sqh.AddModversionToBuild(_buildId, modVersionId);
                            Debug.WriteLine(string.Format("Done addong mod {0} to build", modid));
                        }
                        Debug.WriteLine("Decrementing " + modDir);
                        _processesUsingFolder[modDir]--;
                        Debug.WriteLine("Decremented " + modDir);
                        if (Directory.Exists(modDir) && _processesUsingFolder[modDir] == 0)
                        {
                            while (true)
                            {
                                try
                                {
                                    Debug.WriteLine("Attempting to delete directory " + modDir);
                                    Directory.Delete(modDir, true);
                                    Debug.WriteLine("Done deleting directory " + modDir);
                                    break;
                                }
                                catch (IOException e)
                                {
                                    Debug.WriteLine(e.Message);
                                    Thread.Sleep(100);
                                }
                            }
                            _processesUsingFolder.Remove(modDir);
                        }
                    }
                    if (_processesUsingModID.ContainsKey(mod.Modid))
                        if (_processesUsingModID[mod.Modid] > 1)
                        {
                            _processesUsingModID[mod.Modid]--;
                        }
                        else
                        {
                            _processesUsingModID.Remove(mod.Modid);
                        }
                    _runningProcess--;
                    Debug.WriteLine("Decremented _runningProcess");
                };
                bw.RunWorkerAsync();
            }
            else
            {
                _modsSqLhelper.AddMod(mod.Name, mod.Modid, mod.Version, mod.Mcversion, fileName, modMd5, false);
                while (string.IsNullOrWhiteSpace(_modpackName))
                {
                    _modpackName = Prompt.ShowDialog("What is the Modpack Name?", "Modpack Name");
                }
                while (string.IsNullOrWhiteSpace(_modpackVersion))
                {
                    _modpackVersion = Prompt.ShowDialog("What Version is the modpack?", "Modpack Version");
                }

                string tempDirectory = Path.Combine(_outputDirectory, "tmp");
                string tempModDirectory = Path.Combine(tempDirectory, "mods");
                Directory.CreateDirectory(tempModDirectory);
                string tempFile = Path.Combine(tempModDirectory, fileName);

                int index = tempFile.LastIndexOf(Globalfunctions.PathSeperator);

                string tempFileDirectory = tempFile.Remove(index);
                Directory.CreateDirectory(tempFileDirectory);
                File.Copy(modfile, tempFile, true);

                _modpackArchive = Path.Combine(_outputDirectory, string.Format("{0}-{1}.zip", _modpackName, _modpackVersion));

                if (Globalfunctions.IsUnix())
                {
                    Environment.CurrentDirectory = tempDirectory;
                    _startInfo.Arguments = string.Format("-r \"{0}\" \"{1}\"", _modpackArchive, "mods");
                }
                else
                {
                    _startInfo.Arguments = string.Format("a -y \"{0}\" \"{1}\"", _modpackArchive, tempModDirectory);
                }
                if (Globalfunctions.IsUnix())
                {
                    _startInfo.FileName = "zip";
                }
                _process.StartInfo = _startInfo;
                _process.Start();
                _process.WaitForExit();
                Directory.Delete(tempDirectory, true);
            }

            if (mod.HasBeenWritenToModlist)
                return;
            File.AppendAllText(_modlistTextFile, mod.Name + Environment.NewLine);
            mod.HasBeenWritenToModlist = true;
        }