コード例 #1
0
        public static LoadXmlResult mLoadFromXML()
        {
            LoadXmlResult loadXmlResult = new LoadXmlResult();

            xmlDocument = new XmlDocument();    //creates xml doc
            try
            {
                xmlDocument.Load("Config.xml"); //loads config file to xml doc
            }
            catch
            {
            }

            XmlNodeList pathsList = xmlDocument.GetElementsByTagName("path");

            foreach (XmlNode path in pathsList)      //creates a list of paths to folders
            {
                loadXmlResult.PathList.Add(path.InnerText.ToString());
            }

            /*
             * XmlNodeList freq = xmlDocument.GetElementsByTagName("frequency");
             * loadXmlResult.frequency = freq[0].InnerText.ToString();
             */

            return(loadXmlResult);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.Title = "Pakowanie raportów. Nie zamykać okna. Testy można kontynuować.";

            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);   //disables close button

            var watch = new System.Diagnostics.Stopwatch();

            watch.Start();

            xmlResult = LoadFromXml.mLoadFromXML(); //do xmlResult zapisane są ściezki i częstotliwość z pliku konfiguracyjnego .xml
            foreach (string str in xmlResult.PathList)
            {
                try
                {
                    ZipFiles.ZipFilesInFolder(str);
                }
                catch (System.IO.DirectoryNotFoundException e)
                {
                    Console.WriteLine(Environment.NewLine + "ERROR. PATH NOT FOUND:  " + str);
                    Console.WriteLine("OPERATION STOPPED");
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine(Environment.NewLine + "ERROR:  " + e.ToString());
                    Console.WriteLine("OPERATION STOPPED");
                    break;
                }
            }
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms" + Environment.NewLine + "Operation done. Press enter to exit");
            Console.ReadLine();
        }