Пример #1
0
 /// <summary>
 /// The ContainsItemFLPFile.
 /// </summary>
 /// <param name="item">The item<see cref="FLP_file"/>.</param>
 /// <returns>The <see cref="bool"/>.</returns>
 private bool ContainsItemFLPFile(FLP_file item)
 {
     foreach (FLP_file file in application_config.files)
     {
         if (file.hash == item.hash)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        /// <summary>
        /// The CheckForNewFile.
        /// </summary>
        /// <param name="directory">The directory<see cref="string"/>.</param>
        private void CheckForNewFile(string directory)
        {
            DirectoryInfo d = new DirectoryInfo(directory);

            FileInfo[] Files = d.GetFiles("*.flp");
            foreach (FileInfo file in Files)
            {
                FLP_file new_file = new FLP_file();
                new_file.filepath = directory + "\\" + file.Name;
                Console.WriteLine(new_file.filepath);
                new_file.filename = file.Name;
                new_file.hash     = HashFile(new_file.filepath);
                if (!ContainsItemFLPFile(new_file))
                {
                    application_config.files.Add(new_file);
                    CreateBackupFile(new_file);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// The CreateBackupFile.
        /// </summary>
        /// <param name="file">The file<see cref="FLP_file"/>.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        private async Task CreateBackupFile(FLP_file file)
        {
            file.history.Add(new History(file.filename));
            string file_destination = System.IO.Path.Combine(application_config.destination, file.filename);

            Console.WriteLine(file_destination);
            if (!Directory.Exists(file_destination))
            {
                Directory.CreateDirectory(file_destination);
            }
            try
            {
                Console.WriteLine(file.filename);
                File.Copy(file.filepath, System.IO.Path.Combine(file_destination, get_valid_file_name(DateTime.Now + file.filename)), true);
            }
            catch (IOException iox)
            {
                Console.WriteLine(iox.Message);
            }
        }