Exemple #1
0
        /// <summary>
        /// Tries to get a config file, if that does not exist, then it will create one with the parameters given.
        /// If no parameters are given, it will create one itself with default information.
        /// </summary>
        /// <param name="args">
        /// The first value is the location of the files.
        /// The second value is the port that it will be using.
        /// </param>
        static void Main(string[] args)
        {
            config_dictionary = new Dictionary <string, string>();
            file_catalog      = new List <File_Log>();

            // TESTING STUFF

            // TESTING SAVING

            File_Log test = new File_Log
            {
                File_Path     = "TEST",
                Recent_Change = new DateTime(),
                File_Size     = 100,
                Sha256        = "TESTINGSHA256"
            };
            File_Log test2 = new File_Log
            {
                File_Path     = "TEST2",
                Recent_Change = new DateTime(),
                File_Size     = 1002,
                Sha256        = "TESTINGSHA256"
            };

            file_catalog.Add(test);
            file_catalog.Add(test2);

            SaveCatalog();


            // END OF TESTING STUFF

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\config.ini"))
            {
                //FileInfo FI = new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\config.ini");
                //FI.Length;
            }

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\file_manifest.xml"))
            {
                LoadCatalog();
            }
            //If no arguments are passed, the default location of the files will be a new folder in the same path as the executable.
            if (args.Length == 0)
            {
                config_dictionary["location"] = "\\Files\\";

                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\"))
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\");
                }
            }

            while (true)
            {
                string input = Console.ReadLine();

                ConsoleCommand(input);
            }
        }
Exemple #2
0
        static void LoadCatalog()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\file_catalog.xml");

            file_catalog = new List <File_Log>();

            foreach (XmlNode node in doc.SelectNodes("/FileCatalog/File_Catalog"))
            {
                File_Log file = new File_Log
                {
                    File_Path     = node.Attributes["File_Path"].Value,
                    Recent_Change = DateTime.Parse(node.Attributes["Recent_Change"].Value),
                    File_Size     = int.Parse(node.Attributes["File_Size"].Value),
                    Sha256        = node.Attributes["Sha256"].Value
                };

                file_catalog.Add(file);
            }
        }