Exemplo n.º 1
0
        public List <string> CompareFiles(string path)
        {
            var results = new List <string>();

            var files = Directory.GetFiles(path);

            foreach (string file in files)
            {
                byte[] data = File.ReadAllBytes(file);

                var temp = Files.Where(x => x.Path == file).FirstOrDefault();

                if (temp != null)
                {
                    results.Add($"{file} is coincides with the reference: {CRCFactory.IsItReferenceCRC(temp.CRC, data)} Hash: " +
                                $"{MD5Hash.calculate(data)}");
                }
                else
                {
                    results.Add($"{file} is not exist in base");
                }
            }

            return(results);
        }
Exemplo n.º 2
0
        private void ProcessFile(string path)
        {
            byte[] data = System.IO.File.ReadAllBytes(path);

            var temp = Files.Where(x => x.Path == path).FirstOrDefault();

            if (temp != null)
            {
                Files.Where(x => x.Path == path).FirstOrDefault().CRC = CRCFactory.GetCRC32(data);
            }
            else
            {
                Files.Add(new Models.File()
                {
                    Path = path,
                    CRC  = CRCFactory.GetCRC32(data),
                    Hash = MD5Hash.calculate(data)
                });
            }
        }