public void main(string DateNTime)
        {
            #region string initialization

            string   server = Read.GetFtpServer();
            string   user   = Read.GetFtpUser();
            string   pass   = Read.GetFtpPass();
            string   folder = Read.GetFtpFolder();
            string[] files  = GetFileList();

            #endregion

            try
            {
                foreach (string file in files)
                {
                    Download(file, DateNTime);
                }
            }
            catch (Exception EX)
            {
                Console.WriteLine("Error:" + EX);
                log.MakeLog(EX, null);
            }
        }
        private void Options_Load(object sender, EventArgs e)
        {
            ftpDeXpand.Visible = false;
            FtpExpand.Visible  = true;

            #region textbox loading

            Xml_Reader XML   = new Xml_Reader();
            string     World = XML.GetWorld();
            BackupFrom.Text = World;
            string BackupTime = XML.GetBackupTime();
            BackuptimeText.Text = BackupTime;

            #endregion


            #region load Backup to folder
            string WorldTo = XML.GetBackupTo();
            BackupTo.Text = WorldTo;
            #endregion


            #region ftp loading

            string ftpUser    = XML.GetFtpUser();
            string ftpPass    = XML.GetFtpPass();
            string ftpServer  = XML.GetFtpServer();
            string ftpFolder  = XML.GetFtpFolder();
            string ftpFolder2 = XML.GetFtpFolder2();
            ftpUserText.Text    = ftpUser;
            ftpPassText.Text    = ftpPass;
            ftpServerText.Text  = ftpServer;
            ftpFolderText.Text  = ftpFolder;
            ftpFolder2Text.Text = ftpFolder2;

            #endregion


            #region load checkbox config

            string Compression = XML.UseCompression();
            if (Compression == "yes")
            {
                UseCompression.Checked = true;
            }

            string Update = XML.GetUpdateSettings();
            if (Update == "yes")
            {
                UpdatingCheckBox.Checked = true;
            }

            #endregion
        }
        private void Options_Load(object sender, EventArgs e)
        {
            ftpDeXpand.Visible = false;
            FtpExpand.Visible = true;

            #region textbox loading

            Xml_Reader XML = new Xml_Reader();
            string World = XML.GetWorld();
            BackupFrom.Text = World;
            string BackupTime = XML.GetBackupTime();
            BackuptimeText.Text = BackupTime;

            #endregion

            #region load Backup to folder
            string WorldTo = XML.GetBackupTo();
            BackupTo.Text = WorldTo;
            #endregion

            #region ftp loading

            string ftpUser = XML.GetFtpUser();
            string ftpPass = XML.GetFtpPass();
            string ftpServer = XML.GetFtpServer();
            string ftpFolder = XML.GetFtpFolder();
            string ftpFolder2 = XML.GetFtpFolder2();
            ftpUserText.Text = ftpUser;
            ftpPassText.Text = ftpPass;
            ftpServerText.Text = ftpServer;
            ftpFolderText.Text = ftpFolder;
            ftpFolder2Text.Text = ftpFolder2;

            #endregion

            #region load checkbox config

            string Compression = XML.UseCompression();
            if (Compression == "yes")
            {
                UseCompression.Checked = true;
            }

            string Update = XML.GetUpdateSettings();
            if (Update == "yes")
            {
                UpdatingCheckBox.Checked = true;
            }

            #endregion
        }
        public static string[] GetFileList()
        {
            Error_Logging log  = new Error_Logging();
            Xml_Reader    Read = new Xml_Reader();

            #region string initialization

            string   Server  = Read.GetFtpServer();
            string   User    = Read.GetFtpUser();
            string   Pass    = Read.GetFtpPass();
            string   Folder  = Read.GetFtpFolder();
            string   Folder2 = Read.GetFtpFolder2();
            string[] downloadFiles;

            #endregion


            StringBuilder result   = new StringBuilder();
            WebResponse   responce = null;
            StreamReader  reader   = null;
            try
            {
                FtpWebRequest reqFTP;
                #region FTP details

                reqFTP             = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + Server + "/" + Folder + "/" + Folder2));
                reqFTP.UseBinary   = true;
                reqFTP.Credentials = new NetworkCredential(User, Pass);
                reqFTP.Method      = WebRequestMethods.Ftp.ListDirectory;
                reqFTP.Proxy       = null;
                reqFTP.KeepAlive   = false;
                reqFTP.UsePassive  = false;
                responce           = reqFTP.GetResponse();

                #endregion
                reader = new StreamReader(responce.GetResponseStream());
                string line = reader.ReadLine();
                while (line != null)
                {
                    result.Append(line);
                    result.Append("\n");
                    line = reader.ReadLine();
                }
                result.Remove(result.ToString().LastIndexOf("\n"), 1);
                return(result.ToString().Split('\n'));
            }
            catch (Exception ex)
            {
                log.MakeLog(ex, null);
                #region cleanup

                if (reader != null)
                {
                    reader.Close();
                }
                if (responce != null)
                {
                    responce.Close();
                }
                downloadFiles = null;
                return(downloadFiles);

                #endregion
            }
        }
        public void Upload(string DateNTime)
        {
            string      LocalFolder = Read.GetWorld();
            string      Folder      = Read.GetFtpFolder();
            string      Folder2     = Read.GetFtpFolder2();
            string      User        = Read.GetFtpUser();
            string      Pass        = Read.GetFtpPass();
            string      Server      = Read.GetFtpServer();
            WebResponse responce;

            //throw new NotImplementedException();


            string[]   FILES   = Directory.GetFiles(LocalFolder);
            string[]   fold    = Directory.GetDirectories(LocalFolder);
            WebRequest Request = WebRequest.Create("ftp://" + Server + "/" + Folder + "/" + Folder2);

            Request.Method      = WebRequestMethods.Ftp.MakeDirectory;
            Request.Credentials = new NetworkCredential(User, Pass);


            try
            {
                responce = Request.GetResponse();
            }
            catch (Exception)
            {
                //creates error when the directory already exists, no need to log
                Console.WriteLine("FTP Directory root already exists, continuing...");
            }

            Request             = WebRequest.Create("ftp://" + Server + "/" + Folder + "/" + Folder2 + "/" + DateNTime);
            Request.Method      = WebRequestMethods.Ftp.MakeDirectory;
            Request.Credentials = new NetworkCredential(User, Pass);
            try
            {
                responce = Request.GetResponse();
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error has occured:r\n\"" + ex);
                Console.ReadKey();
                log.MakeLog(ex, null);
            }


            var path    = LocalFolder;
            var dirName = new DirectoryInfo(path).Name;

            #region Create Directories and copy files
            foreach (string dir in fold)
            {
                dirName = new DirectoryInfo(dir).Name;
                string[] Files = Directory.GetFiles(dir);


                Request             = WebRequest.Create("ftp://" + Server + "/" + Folder + "/" + Folder2 + "/" + DateNTime + "/" + dirName);
                Request.Method      = WebRequestMethods.Ftp.MakeDirectory;
                Request.Credentials = new NetworkCredential(User, Pass);
                try
                {
                    responce = Request.GetResponse();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error has occurred:r\n\"" + ex);
                    Console.ReadKey();
                    log.MakeLog(ex, null);
                }

                foreach (string file1 in Files)
                {
                    if (file1 == null)
                    {
                        break;
                    }
                    WebClient client = new WebClient();
                    client.Credentials = new NetworkCredential(User, Pass);
                    try
                    {
                        client.UploadFile("ftp://" + Server + "/" + Folder + "/" + Folder2 + "/" + DateNTime + "/" +
                                          dirName + "/" + new FileInfo(file1).Name, "STOR", file1);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An error has occured:r\n\"" + ex);
                        Console.ReadKey();
                        log.MakeLog(ex, null);
                    }
                }
            }
            #endregion

            #region Copy files from root folder
            foreach (string files in FILES)
            {
                WebClient client = new WebClient();
                client.Credentials = new NetworkCredential(User, Pass);
                try
                {
                    client.UploadFile("ftp://" + Server + "/" + Folder + "/" + Folder2 + "/" + DateNTime + "/" +
                                      new FileInfo(files).Name, "STOR", files);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error has occured:r\n\"" + ex);
                    Console.ReadKey();
                    log.MakeLog(ex, null);
                }
            }
            #endregion
            Console.WriteLine("Finished FTP upload of world.");
            Console.ReadKey();
        }
        public static string[] GetFileList()
        {
            Error_Logging log = new Error_Logging();
            Xml_Reader Read = new Xml_Reader();

            #region string initialization

            string Server = Read.GetFtpServer();
            string User = Read.GetFtpUser();
            string Pass = Read.GetFtpPass();
            string Folder = Read.GetFtpFolder();
            string Folder2 = Read.GetFtpFolder2();
            string[] downloadFiles;

            #endregion

            StringBuilder result = new StringBuilder();
            WebResponse responce = null;
            StreamReader reader = null;
            try
            {
                FtpWebRequest reqFTP;
                #region FTP details

                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + Server + "/" + Folder + "/" + Folder2));
                reqFTP.UseBinary = true;
                reqFTP.Credentials = new NetworkCredential(User, Pass);
                reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
                reqFTP.Proxy = null;
                reqFTP.KeepAlive = false;
                reqFTP.UsePassive = false;
                responce = reqFTP.GetResponse();

                #endregion
                reader = new StreamReader(responce.GetResponseStream());
                string line = reader.ReadLine();
                while (line != null)
                {
                    result.Append(line);
                    result.Append("\n");
                    line = reader.ReadLine();
                }
                result.Remove(result.ToString().LastIndexOf("\n"), 1);
                return result.ToString().Split('\n');
            }
            catch(Exception ex)
            {
                log.MakeLog(ex,null);
                #region cleanup

                if (reader != null)
                {
                    reader.Close();
                }
                if (responce != null)
                {
                    responce.Close();
                }
                downloadFiles = null;
                return downloadFiles;

                #endregion
            }
        }