示例#1
0
        /// <summary>
        /// Reads an XML file to parse configuration information.
        /// </summary>
        /// <param name="ConfigFilePath">Path to XML File</param>
        /// <returns>Returns a Machine_Settings object containing information found.</returns>
        public static DeviceConfiguration Read(string path)
        {
            DeviceConfiguration result = null;

            if (File.Exists(path))
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(path);

                    result = Read(doc);

                    if (result.UniqueId == null)
                    {
                        result.UniqueId = GenerateUniqueID();
                        XML_Functions.SetInnerText(result.Xml, "/UniqueId", result.UniqueId);
                    }
                }
                catch (XmlException ex) { logger.Error(ex); }
                catch (Exception ex) { logger.Error(ex); }
            }
            else
            {
                logger.Warn("Configuration File Not Found : " + path);
            }

            return(result);
        }
        public static UpdateConfiguration Read()
        {
            var result = new UpdateConfiguration();

            var xml = XML_Functions.ReadDocument(CONFIG_FILEPATH);

            if (xml != null)
            {
                foreach (XmlNode node in xml.DocumentElement.ChildNodes)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        if (node.InnerText != "")
                        {
                            Type         Settings = typeof(UpdateConfiguration);
                            PropertyInfo info     = Settings.GetProperty(node.Name);

                            if (info != null)
                            {
                                Type t = info.PropertyType;
                                info.SetValue(result, Convert.ChangeType(node.InnerText, t), null);
                            }
                        }
                    }
                }
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// Récupère la liste des machines - Get the list of machines
        /// </summary>
        /// todo: put a possibility to get file manually
        private void FillListMachines()
        {
            // Show new controls
            lbSystems.Visible = lboxMachines.Visible = true;
            lbGames.Visible   = lvGames.Visible = true;

            string xmlLMachines = Path.Combine(_lbPath, Properties.Settings.Default.fPlatforms);

            Console.WriteLine(xmlLMachines);
            XML_Functions xf = new XML_Functions();

            if (xf.ReadFile(xmlLMachines))
            {
                List <string> lm = new List <string>()
                {
                    Lang.SelectASystem
                };
                xf.ListMachine(lm);

                lboxMachines.DataSource = lm;
            }
            else
            {
                //30/10/2020

                /*
                 * Properties.Settings.Default.LBPath = null;
                 * Properties.Settings.Default.Save();*/
                //30/10/2020
                _lbPath = null;
                // LaunchBoxPath.Text = null;
            }
        }
        public static LoginData Read()
        {
            LoginData result = null;

            string path = Path.Combine(FileLocations.TrakHound, SERVER_CREDENTIALS_FILENAME);

            if (File.Exists(path))
            {
                try
                {
                    var xml = new XmlDocument();
                    xml.Load(path);

                    string username = XML_Functions.GetInnerText(xml, "Username");
                    string token    = XML_Functions.GetInnerText(xml, "Token");

                    if (username != null && token != null)
                    {
                        result          = new LoginData();
                        result.Username = username;
                        result.Token    = token;
                    }
                }
                catch (Exception ex) { logger.Error(ex); }
            }

            return(result);
        }
示例#5
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Math.Min(80, Console.LargestWindowWidth), Math.Min(60, Console.LargestWindowHeight));
            // Get the object used to communicate with the server.
            XML_Functions.Connection ftp_connection = new XML_Functions.Connection();


            try
            {
                XML_Functions.Create_XML_Settings_File();
                XML_Functions.Read_XML_Settings_File(ftp_connection);

                List <String> files = new List <String>();
                files.Add(@"//usr/configs/sfty.dat");
                files.Add(@"//usr/temp/pdrv.sys");
                files.Add(@"//usr/temp/pdrv.dat");

                Console.WriteLine(string.Format("New Connection to IP : {0}", ftp_connection.IP));
                Console.WriteLine(string.Format("Username : {0} , Password : {1}", ftp_connection.Username, ftp_connection.Password));

                // create an FTP client
                FtpClient client = new FtpClient(ftp_connection.IP);

                // if you don't specify login credentials, we use the "anonymous" user account
                client.Credentials = new NetworkCredential(ftp_connection.Username, ftp_connection.Password);

                // begin connecting to the server
                client.Connect();


                foreach (String file in files)
                {
                    if (client.FileExists(file))
                    {
                        client.DeleteFile(file);
                        Console.WriteLine(file + " deleted");
                    }
                }

                client.Disconnect();
                Unicorn.show();
                Thread.Sleep(500);
                //Console.ReadKey();
                // File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", result);

                // FileStream txtfile = File.Create(@"C:\test.txt");
                //File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", reader.ReadToEnd());
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                //Console.ReadKey();
            }
        }
        public static bool Create(UpdateConfiguration config)
        {
            bool result = false;

            Remove();

            if (config != null)
            {
                var xml = CreateDocument(config);
                XML_Functions.WriteDocument(xml, CONFIG_FILEPATH);
            }

            return(result);
        }
            public static AgentConfiguration Read(DeviceConfiguration config)
            {
                var result = new AgentConfiguration();

                result.Address = XML_Functions.GetInnerText(config.Xml, "//Agent/Address");

                int port = 80;

                int.TryParse(XML_Functions.GetInnerText(config.Xml, "//Agent/Port"), out port);
                result.Port = port;

                result.DeviceName = XML_Functions.GetInnerText(config.Xml, "//Agent/DeviceName");

                return(result);
            }
示例#8
0
        /// <summary>
        /// Récupère la liste des jeux - Get the list of games
        /// </summary>
        private void FillListGames()
        {
            _xfGames = new XML_Functions();

            lvGames.Items.Clear();

            if (_xfGames.ReadFile(_XmlFPlatform))
            {
                _GameList = _xfGames.ListGames();

                // var lgSorted = lg.OrderBy(x => x.FileName).ToList();

                //foreach (ShortGame sg in lgSorted)
                //{
                //    ListViewItem lvi = new ListViewItem(sg.Title);

                //    lvi.Tag = sg.ID;
                //    lvi.SubItems.Add(sg.Region);
                //    lvi.SubItems.Add(sg.FileName);

                //    lvGames.Items.Add(lvi);
                //}

                foreach (var sGame in _GameList.Values.OrderBy(x => x.Title))
                {
                    ListViewItem lvi = new ListViewItem(sGame.Title);

                    lvi.Tag = sGame;
                    lvi.SubItems.Add(sGame.Region);
                    lvi.SubItems.Add(sGame.FileName);

                    lvGames.Items.Add(lvi);
                }
            }
            else
            {
            }

            lvGames.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            // lvGames.Columns[1].Width = 0;
        }
示例#9
0
        public static bool Save(XmlDocument xml, string path)
        {
            bool result = false;

            if (xml != null)
            {
                try
                {
                    string filePath = XML_Functions.GetInnerText(xml, "UniqueId");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    xml.Save(Path.Combine(path, Path.ChangeExtension(filePath, ".xml")));

                    result = true;
                }
                catch (Exception ex) { logger.Error(ex); }
            }

            return(result);
        }
示例#10
0
        public static bool Save(XmlDocument xml, string path)
        {
            bool result = false;

            if (xml != null)
            {
                try
                {
                    string filePath = XML_Functions.GetInnerText(xml, "UniqueId");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    xml.Save(Path.Combine(path, Path.ChangeExtension(filePath, ".xml")));

                    result = true;
                }
                catch (Exception ex) { Logger.Log("Error during Configuration Xml Save : " + ex.Message, LogLineType.Warning); }
            }

            return(result);
        }
示例#11
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Math.Min(80, Console.LargestWindowWidth), Math.Min(60, Console.LargestWindowHeight));
            // Get the object used to communicate with the server.
            XML_Functions.Connection ftp_connection = new XML_Functions.Connection();

            StringBuilder result = new StringBuilder();

            try
            {
                XML_Functions.Create_XML_Settings_File();
                XML_Functions.Read_XML_Settings_File(ftp_connection);


                Console.WriteLine(string.Format("New Connection to IP : {0}", ftp_connection.IP));
                Console.WriteLine(string.Format("Username : {0} , Password : {1}", ftp_connection.Username, ftp_connection.Password));


                Staubli_Folder_Structure.xml_info_files.controller_file.Localfilename  = ftp_connection.Path + "temp_controller.xml";
                Staubli_Folder_Structure.xml_info_files.arm_file.Localfilename         = ftp_connection.Path + "temp_arm.xml";
                Staubli_Folder_Structure.xml_info_files.val3version_file.Localfilename = ftp_connection.Path + "temp_val3version.xml";
                List <string> tempfiles = new List <string>();
                tempfiles.Add(Staubli_Folder_Structure.xml_info_files.arm_file.Localfilename);
                tempfiles.Add(Staubli_Folder_Structure.xml_info_files.controller_file.Localfilename);
                tempfiles.Add(Staubli_Folder_Structure.xml_info_files.val3version_file.Localfilename);

                // create an FTP client
                FtpClient client = new FtpClient(ftp_connection.IP);

                // if you don't specify login credentials, we use the "anonymous" user account
                client.Credentials = new NetworkCredential(ftp_connection.Username, ftp_connection.Password);

                // begin connecting to the server
                client.Connect();

                foreach (FtpListItem item in client.GetListing(Staubli_Folder_Structure.paths.config_path))
                {
                    if (item.Type == FtpFileSystemObjectType.File)
                    {
                        if (item.FullName.Contains("arm"))
                        {
                            if (item.FullName.Contains("cfx"))
                            {
                                Staubli_Folder_Structure.xml_info_files.arm_file.Ftpfilename = item.FullName;
                            }
                        }
                    }
                }

                //Console.WriteLine(Staubli_Folder_Structure.xml_info_files.controller_file.Localfilename + "  " + Staubli_Folder_Structure.xml_info_files.controller_file.Ftpfilename);
                if (client.FileExists(Staubli_Folder_Structure.xml_info_files.controller_file.Ftpfilename))
                {
                    client.DownloadFile(Staubli_Folder_Structure.xml_info_files.controller_file.Localfilename, Staubli_Folder_Structure.xml_info_files.controller_file.Ftpfilename);
                }
                if (client.FileExists(Staubli_Folder_Structure.xml_info_files.arm_file.Ftpfilename))
                {
                    client.DownloadFile(Staubli_Folder_Structure.xml_info_files.arm_file.Localfilename, Staubli_Folder_Structure.xml_info_files.arm_file.Ftpfilename);
                }
                if (client.FileExists(Staubli_Folder_Structure.xml_info_files.val3version_file.Ftpfilename))
                {
                    client.DownloadFile(Staubli_Folder_Structure.xml_info_files.val3version_file.Localfilename, Staubli_Folder_Structure.xml_info_files.val3version_file.Ftpfilename);
                }
                client.Disconnect();

                Staubli_Folder_Structure.xml_info_files.controller_file.ItemsList.Add(Staubli_Folder_Structure.xml_items.PowerHourCount);
                Staubli_Folder_Structure.xml_info_files.controller_file.ItemsList.Add(Staubli_Folder_Structure.xml_items.ControlerSerialNumber);

                Staubli_Folder_Structure.xml_info_files.arm_file.ItemsList.Add(Staubli_Folder_Structure.xml_items.ArmOrderNumber);
                Staubli_Folder_Structure.xml_info_files.arm_file.ItemsList.Add(Staubli_Folder_Structure.xml_items.RobotType);

                Staubli_Folder_Structure.xml_info_files.val3version_file.ItemsList.Add(Staubli_Folder_Structure.xml_items.Val3Version);

                XML_Functions.Read_XML_File_Item(Staubli_Folder_Structure.xml_info_files.controller_file);
                XML_Functions.Read_XML_File_Item(Staubli_Folder_Structure.xml_info_files.arm_file);
                XML_Functions.Read_XML_File_Item(Staubli_Folder_Structure.xml_info_files.val3version_file);


                Console.WriteLine("PowerHourCount           : " + Staubli_Folder_Structure.xml_items.PowerHourCount.Value);
                Console.WriteLine("Arm Order number         : " + Staubli_Folder_Structure.xml_items.ArmOrderNumber.Value);
                Console.WriteLine("Controler Serial number  : " + Staubli_Folder_Structure.xml_items.ControlerSerialNumber.Value);
                Console.WriteLine("Robottype                : " + Staubli_Folder_Structure.xml_items.RobotType.Value);
                Console.WriteLine("Val3Version              : " + Staubli_Folder_Structure.xml_items.Val3Version.Value);

                result.Append(Staubli_Folder_Structure.xml_items.PowerHourCount.Value + Environment.NewLine);
                result.Append(Staubli_Folder_Structure.xml_items.ArmOrderNumber.Value + Environment.NewLine);
                result.Append(Staubli_Folder_Structure.xml_items.ControlerSerialNumber.Value + Environment.NewLine);
                result.Append(Staubli_Folder_Structure.xml_items.RobotType.Value + Environment.NewLine);
                result.Append(Staubli_Folder_Structure.xml_items.Val3Version.Value + Environment.NewLine);

                XML_Functions.Delete_XML_Files(tempfiles);
                if (File.Exists(ftp_connection.Informationfilename))
                {
                    File.Delete(ftp_connection.Informationfilename);
                }
                File.WriteAllText(ftp_connection.Informationfilename, result.ToString());

                Unicorn.show();
                Thread.Sleep(500);
                // Console.ReadKey();
                // File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", result);

                // FileStream txtfile = File.Create(@"C:\test.txt");
                //File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", reader.ReadToEnd());
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                Console.ReadKey();
            }
        }
示例#12
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Math.Min(80, Console.LargestWindowWidth), Math.Min(60, Console.LargestWindowHeight));
            // Get the object used to communicate with the server.
            XML_Functions.Connection ftp_connection = new XML_Functions.Connection();


            try
            {
                XML_Functions.Create_XML_Settings_File();
                XML_Functions.Read_XML_Settings_File(ftp_connection);
                if (File.Exists(ftp_connection.Path + ftp_connection.Filename))
                {
                    File.Delete(ftp_connection.Path + ftp_connection.Filename);
                }
                if (File.Exists(ftp_connection.Path + "errors.log"))
                {
                    File.Delete(ftp_connection.Path + "errors.log");
                }
                Console.WriteLine(string.Format("New Connection to IP : {0}", ftp_connection.IP));
                Console.WriteLine(string.Format("Username : {0} , Password : {1}", ftp_connection.Username, ftp_connection.Password));
                Console.WriteLine(string.Format("Datapath : {0} , Filename : {1}", ftp_connection.Path, ftp_connection.Filename));

                StringBuilder result = new StringBuilder();

                string line = "";
                msgclass = ftp_connection.MsgClass;
                // This example assumes the FTP site uses anonymous logon.

                // create an FTP client
                FtpClient client = new FtpClient(ftp_connection.IP);

                // if you don't specify login credentials, we use the "anonymous" user account
                client.Credentials = new NetworkCredential(ftp_connection.Username, ftp_connection.Password);

                // begin connecting to the server
                client.Connect();

                client.DownloadFile(ftp_connection.Path + "errors.log", Staubli_Folder_Structure.files.logfile_path);

                client.Disconnect();

                if (File.Exists(ftp_connection.Path + "errors.log"))
                {
                    using (StreamReader reader = new StreamReader(ftp_connection.Path + "errors.log"))
                    {
                        result.Append(StaticText.header + Environment.NewLine);
                        while ((line = reader.ReadLine()) != null)
                        {
                            result.Append(string.Format(@"41860806845.6366;2;1;{1};1;""{0}"";;;;;;;;""07.05.2017 19:56:51"";"""";""""", line, msgclass) + Environment.NewLine);
                        }
                        // Console.WriteLine("Download Complete, status {0}", response.StatusDescription);

                        result.Append(StaticText.end + Environment.NewLine);
                    }
                }

                File.WriteAllText(ftp_connection.Path + ftp_connection.Filename, result.ToString());
                Unicorn.show();
                Thread.Sleep(500);
                // File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", result);

                // FileStream txtfile = File.Create(@"C:\test.txt");
                //File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\errors.log", reader.ReadToEnd());
            }
            catch (Exception e)
            {
                String result = "";

                result += StaticText.header + Environment.NewLine;
                result += string.Format(@"41860806845.6366;2;1;{1};1;""{0}"";;;;;;;;""07.05.2017 19:56:51"";"""";""""", e.Message, msgclass) + Environment.NewLine;
                result += StaticText.end + Environment.NewLine;
                File.WriteAllText(ftp_connection.Path + ftp_connection.Filename, result);

                Console.Write(e.Message);
            }
        }
示例#13
0
        /// <summary>
        /// ...
        /// Créer un fichier xml après collection des données dans le fichier xml de launchbox si activé
        /// </summary>
        /// <param name="xFile">believe... xml file </param>
        /// <param name="GameFile">Game file (exploitable)</param>
        internal int Initialize(string xFile, ShortGame sGame)
        {
            // Verif
            if (string.IsNullOrEmpty(ID))
            {
                throw new Exception("Id property: null");
            }

            if (string.IsNullOrEmpty(_SystemName))
            {
                throw new Exception();
            }

            _WFolder = Properties.Settings.Default.OutPPath;

            // Chemin du dossier temporaire du system
            _SystemPath = Path.Combine(_WFolder, _SystemName);
            _GamePath   = Path.Combine(_SystemPath, $"{sGame.ExploitableFileName}");           // New Working Folder
            string logFile = Path.Combine(_WFolder, $"{_SystemName} - {sGame.ExploitableFileName}.log");


            // Todo peut être déclencher un event sur le stop pour couper net ?
            var folderRes = OPFolders.SVerif(_GamePath, "Initialize", Dcs_Buttons.NoPass | Dcs_Buttons.NoRename, (string message) => ITrace.WriteLine(message, true));

            if (folderRes == EDestDecision.Stop)
            {
                //
                ITrace.WriteLine("[Initialize] GoodBye !");
                if (_IScreen != null)
                {
                    _IScreen.Close();
                }

                ITrace.RemoveListener(_IScreen);

                return(200);
            }

            #region System d'affichage
            string prefix = "PackMe";
            //window
            if (Settings.Default.opLogWindow)
            {
                _IScreen        = new InfoScreen();
                _IScreen.Prefix = prefix;
                _IScreen.Show();
                _Loggers.Add(_IScreen);
            }

            // file
            if (Settings.Default.opLogFile)
            {
                InfoToFile iLog = new InfoToFile(logFile, true);
                iLog.Prefix = prefix;
                _Loggers.Add(iLog);
            }

            // debug
            if (Debugger.IsAttached)
            {
                InfoToConsole iConsole = new InfoToConsole();
                iConsole.Prefix = prefix;
                _Loggers.Add(iConsole);
            }

            ITrace.AddListeners(_Loggers);


            ITrace.WriteLine("===== Report of errors: =====");
            ITrace.WriteLine($"[Initialize] ID:\t'{ID}'");
            ITrace.WriteLine($"[Initialize] {Lang.SystemSelected}: '{_SystemName}'");
            ITrace.WriteLine($"[Initialize] {Lang.GameSelected}: '{sGame.Title}' - Rom: '{sGame.ExploitableFileName}'");


            #endregion

            /*
             * BackgroundWorker bw = new BackgroundWorker();
             * bw.DoWork += new DoWorkEventHandler(BwWork); // PackMe.Initialize(_XmlFPlatform);
             * bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BWRunWorkerCompleted);
             * bw.RunWorkerAsync();
             */

            // Lecture du fichier platform
            XML_Functions xmlPlatform = new XML_Functions();
            xmlPlatform.ReadFile(Path.Combine(Properties.Settings.Default.LBPath, Properties.Settings.Default.fPlatforms));

            _ZePlatform = xmlPlatform.ScrapPlatform(_SystemName);

            // Reconstruct PlatformFolder Path
            foreach (PlatformFolder plfmFolder in _ZePlatform.PlatformFolders)
            {
                plfmFolder.FolderPath = ReconstructPath(plfmFolder.FolderPath);
            }

            // Lecture du fichier des jeux
            _XFunctions = new XML_Functions();
            _XFunctions.ReadFile(xFile);

            // Get Main infos
            _zBackGame = _XFunctions.ScrapBackupGame(ID);
            _ZeGame    = (GameInfo)_zBackGame;

            #region 2020

            // Creation of System folder and working assign
            ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_SystemName}'");
            Directory.CreateDirectory(_SystemName);
            Directory.SetCurrentDirectory(_SystemPath);

            // Creation of Game folder
            ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_GamePath}'");
            Directory.CreateDirectory(_GamePath);
            #endregion


            #region Original Backup Game
            if (Settings.Default.opOBGame)
            {
                MakeXML.Backup_Game(_GamePath, _zBackGame, "TBGame");
            }
            else
            {
                ITrace.WriteLine("[Run] Original Backup Game disabled");
            }
            #endregion

            _LBoxDI = new DirectoryInfo(Settings.Default.LBPath);

            // Set active Directory to Root
            Directory.SetCurrentDirectory(_WFolder);

            #region Paths reconstruction

            _zBackGame.ApplicationPath = ReconstructPath(_zBackGame.ApplicationPath);
            _zBackGame.ManualPath      = ReconstructPath(_zBackGame.ManualPath);
            _zBackGame.MusicPath       = ReconstructPath(_zBackGame.MusicPath);
            _zBackGame.VideoPath       = ReconstructPath(_zBackGame.VideoPath);
            #endregion


            return(0);
        }
示例#14
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Math.Min(100, Console.LargestWindowWidth), Math.Min(60, Console.LargestWindowHeight));
            // Get the object used to communicate with the server.
            XML_Functions.Connection ftp_connection = new XML_Functions.Connection();

            List <string> files       = new List <string>();
            List <string> directories = new List <string>();


            string backupname = DateTime.Now.ToString("Y-yyyy M-MM D-dd hh_mm");

            try
            {
                XML_Functions.Create_XML_Settings_File();
                XML_Functions.Read_XML_Settings_File(ftp_connection);
                // create an FTP client

                Console.WriteLine(string.Format("New Connection to IP : {0}", ftp_connection.IP));
                Console.WriteLine(string.Format("Username : {0} , Password : {1}", ftp_connection.Username, ftp_connection.Password));

                // create an FTP client
                FtpClient client = new FtpClient(ftp_connection.IP);

                // if you don't specify login credentials, we use the "anonymous" user account
                client.Credentials = new NetworkCredential(ftp_connection.Username, ftp_connection.Password);

                // begin connecting to the server
                client.Connect();

                Stopwatch watch = new Stopwatch();
                watch.Start();
                // get a list of files and directories in the "/htdocs" folder
                foreach (string rootfolder in Staubli_Folder_Structure.paths.rootfolders)
                {
                    directories.Add(rootfolder);
                    foreach (FtpListItem item in client.GetListing(rootfolder))
                    {
                        if (item.Type == FtpFileSystemObjectType.File)
                        {
                            files.Add(item.FullName);
                        }
                        if (item.Type == FtpFileSystemObjectType.Directory)
                        {
                            directories.Add(item.FullName);
                            SearchFiles.getfiles(files, directories, item.FullName, client);
                        }
                    }
                }

                //Create Directories
                foreach (string directory in directories)
                {
                    //Console.WriteLine(ftp_connection.Path + "\\" + backupname + "\\" + directory);
                    System.IO.Directory.CreateDirectory(ftp_connection.Path + "\\" + backupname + "\\" + directory);
                }
                string temp = "";
                string path = "";
                //Put Files in to
                using (var progress = new ProgressBar())
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        temp = files[i].Split('/').Last();
                        path = files[i].Substring(0, files[i].Length - temp.Length - 1);

                        foreach (string directory in directories)
                        {
                            if (string.Equals(path, directory))
                            {
                                client.DownloadFile(ftp_connection.Path + "\\" + backupname + "\\" + path + "\\" + temp, files[i]);
                                progress.Report((double)i / files.Count);
                                progress.Report(files[i].Substring(0, Math.Min(files[i].Length, 65)));
                            }
                        }
                    }
                }

                Console.WriteLine("Backup in Folder : " + backupname + " created");
                client.Disconnect();
                watch.Stop();
                Console.WriteLine(string.Format("Benchmark : {0}", watch.ElapsedMilliseconds));
                Unicorn.show();
                Thread.Sleep(500);
                // Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }
        }