/// <summary>
        /// returns true if info1 is larger then info2
        /// </summary>
        /// <param name="info1"></param>
        /// <param name="info2"></param>
        /// <returns></returns>
        private bool VersionInfo1LargerThenInfo2(xmlVersionInfo info1, xmlVersionInfo info2)
        {
            bool returnValue = false;
            if (info1.VersionMajor > info2.VersionMajor)
                returnValue = true;
            else if (info1.VersionMajor == info2.VersionMajor && info1.VersionMinor > info2.VersionMinor)
                returnValue = true;
            else if (info1.VersionMajor == info2.VersionMajor && info1.VersionMinor == info2.VersionMinor && info1.VersionRevision > info2.VersionRevision)
                returnValue = true;
            else if (info1.VersionMajor == info2.VersionMajor && info1.VersionMinor == info2.VersionMinor && info1.VersionRevision == info2.VersionRevision && info1.VersionPack > info2.VersionPack)
                returnValue = true;

            return returnValue;
        }
        //public void DownloadInstallPackAndStartGame(object oPackName)
        //{
        //    try
        //    {
        //        if (!CloseAllThreads)
        //            if(DownloadAndInstallPackWorker((string)oPackName))
        //                StartGame((string)oPackName);
        //    }
        //    catch (Exception ex)
        //    {
        //        ex.Data.Add("DownloadInstallPackAndStartGame() - oPackName", oPackName.ToString());
        //        ErrorReporting(ex, false);
        //    }
        //}
        //public void DownloadAndInstallPack(object oPackName)
        //{
        //    try
        //    {
        //        if (!CloseAllThreads)
        //            DownloadAndInstallPackWorker((string)oPackName);
        //    }
        //    catch (Exception ex)
        //    {
        //        ex.Data.Add("DownloadAndInstallPack() - oPackName", oPackName.ToString());
        //        ErrorReporting(ex, false);
        //    }
        //}
        ///// <summary>
        ///// This method should NEVER be called by anything other then DownloadAndInstallPack() and DownloadInstallPackAndStartGame()
        ///// Code help thanks to http://www.devtoolshed.com/content/c-download-file-progress-bar
        ///// </summary>
        ///// <param name="pack"></param>
        //private bool DownloadAndInstallPackWorker(string packName)
        //{
        //    //string packName = "";
        //    Uri urlString = null;
        //    string filename = "";
        //    bool returnValue = false;
        //    string MethodProgress = "";
        //    try
        //    {
        //        //packName = (string)oPackName;
        //        //FormOptions.SupportetAutoUpdatePack pack = (FormOptions.SupportetAutoUpdatePack)oPack;
        //        MethodProgress = "creating URI";
        //        urlString = new Uri(_formOptions.PackUpdateUrl(packName));
        //        filename = urlString.OriginalString.Substring(urlString.OriginalString.LastIndexOf("/") + 1, urlString.OriginalString.Length - urlString.OriginalString.LastIndexOf("/") - 1);
        //        //_formNews = new FormNews(_formOptions.GetVersionInfo(packName, true).UpdateNews);
        //        //_formNews.Show();
        //        //_formNews.Focus();
        //        MethodProgress = "SetAndShowNews";
        //        SetAndShowNews(_formOptions.GetVersionInfo(packName, true).UpdateNews);
        //        //Download file
        //        MethodProgress = "Downloading file";
        //        returnValue = DownloadFile(urlString, filename);
        //        //extract file
        //        MethodProgress = "Extracting File";
        //        ExtractFile(packName, filename);
        //        //this.Invoke(new Action(delegate() { this.UpdatePackSelect(); }));
        //        //StartGame(packName);
        //        //MessageBox.Show("DEBUG - Game startet " + packName);
        //        //test if extract successful? (if minecraft.jar exists)
        //    }
        //    catch (Exception ex)
        //    {
        //        SetDownloadPanelVisibility(false);
        //        ex.Data.Add("DownloadAndInstallPack() - packName", packName);
        //        ex.Data.Add("DownloadAndInstallPack() - filename", filename);
        //        ex.Data.Add("DownloadAndInstallPack() - MethodProgress", MethodProgress);
        //        ErrorReporting(ex, false);
        //    }
        //    SetDownloadPanelVisibility(false);
        //    return returnValue;
        //}
        private bool DoBackup(string targetFolder, string backupFolder, xmlVersionInfo versionInfo)
        {
            string MethodProgress = "";
            try
            {
                if (Directory.Exists(targetFolder)) //skipping backup if theres nothing to backup
                {
                    string fullPath = "";
                    FileAttributes attr;

                    SetDownloadLabelTextMain("Creating backup");
                    SetDownloadProgressbarMarqueueStyle(ProgressBarStyle.Marquee);
                    MethodProgress = "starting Backup";

                    foreach (string excludeInfo in versionInfo.ExcludeFromUpdate)
                    {
                        if (CloseAllThreads)
                            break;

                        fullPath = targetFolder + "\\" + excludeInfo;

                        if (Directory.Exists(fullPath) || File.Exists(fullPath))
                        {

                            attr = File.GetAttributes(fullPath);
                            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                            {
                                //directory
                                string tmpStr = backupFolder + "\\" + excludeInfo;
                                if (excludeInfo.Contains("\\"))
                                {
                                    string tmpStr2 = tmpStr.Substring(0, tmpStr.LastIndexOf("\\"));
                                    if (!Directory.Exists(tmpStr2))
                                        Directory.CreateDirectory(tmpStr2);
                                    //tmpStr2 = tmpStr2;
                                }
                                MethodProgress = "moving - Directory";
                                if (Directory.Exists(tmpStr))
                                {
                                    CopyAll(new DirectoryInfo(fullPath), new DirectoryInfo(tmpStr));
                                    DeleteDirectory(fullPath);
                                }
                                else
                                    Directory.Move(fullPath, tmpStr);
                            }
                            else
                            {
                                FileInfo fInfo = new FileInfo(backupFolder + "\\" + excludeInfo);
                                if (!Directory.Exists(fInfo.DirectoryName))
                                    Directory.CreateDirectory(fInfo.DirectoryName);

                                //file
                                MethodProgress = "moving - File";
                                File.Move(fullPath, backupFolder + "\\" + excludeInfo);
                            }
                        }
                    }

                    //cleaning out
                    MethodProgress = "Cleanup";
                    if (!CloseAllThreads)
                    {
                        DeleteDirectory(targetFolder);
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                ex.Data.Add("DoBackup() - targetFolder", targetFolder);
                ex.Data.Add("DoBackup() - backupFolder", backupFolder);
                ex.Data.Add("DoBackup() - MethodProgress", MethodProgress);
                throw ex;
            }
        }
        public xmlVersionInfo GetClientVersion()
        {
            xmlVersionInfo returnValue = new xmlVersionInfo();
            try
            {
                Assembly ass = Assembly.GetExecutingAssembly();

                if (ass != null)
                {
                    FileVersionInfo FVI = FileVersionInfo.GetVersionInfo(ass.Location);
                    returnValue.VersionMajor = FVI.FileMajorPart;
                    returnValue.VersionMinor = FVI.FileMinorPart;
                    returnValue.VersionRevision = FVI.FileBuildPart;
                    returnValue.VersionPack = FVI.FilePrivatePart;
                    //returnValue += (double)FVI.FileMinorPart / 1000;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return returnValue;
        }
        /// <summary>
        /// Gets an xmlVersionInfo object with information about the version and news extracted from the xml file
        /// </summary>
        /// <param name="pack">SupportetAutoUpdatePack type of pack to retrieve information from</param>
        /// <param name="remoteFile">true: getting info from a web link, false: get the info froma  local file on the harddrive</param>
        /// <returns></returns>
        public xmlVersionInfo GetVersionInfo(string packName, bool remoteFile)
        {
            xmlVersionInfo returnInfo = new xmlVersionInfo();
            try
            {
                switch (packName)
                {
                    case _packIRName:
                        if (remoteFile)
                            returnInfo = new xmlVersionInfo(_packIRUpdateVersionUrl, true);
                        else
                            returnInfo = new xmlVersionInfo(Application.StartupPath + "\\Minecraft Packs\\" + _packIRName + "\\PackInfo.xml", false);
                        break;
                    case _packERName:
                        if (remoteFile)
                            returnInfo = new xmlVersionInfo(_packERUpdateVersionUrl, true);
                        else
                            returnInfo = new xmlVersionInfo(Application.StartupPath + "\\Minecraft Packs\\" + _packERName + "\\PackInfo.xml", false);
                        break;
                    case _packTFCRName:
                        if (remoteFile)
                            returnInfo = new xmlVersionInfo(_packTFCRUpdateVersionUrl, true);
                        else
                            returnInfo = new xmlVersionInfo(Application.StartupPath + "\\Minecraft Packs\\" + _packTFCRName + "\\PackInfo.xml", false);
                        break;
                    case _packVanillaName:
                        if (remoteFile)
                            returnInfo = new xmlVersionInfo(_packVanillaUpdateVersionUrl, true);
                        else
                            returnInfo = new xmlVersionInfo(Application.StartupPath + "\\Minecraft Packs\\" + _packVanillaName + "\\PackInfo.xml", false);
                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return returnInfo;
        }
        public xmlVersionInfo GetClientUpdateInfo()
        {
            xmlVersionInfo returnInfo = new xmlVersionInfo();

            try
            {
                returnInfo = new xmlVersionInfo(_KBGClientVersionUrl, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return returnInfo;
        }