예제 #1
0
        static bool ExtractFile(ColumbiaFile file)
        {
            string name = String.Format("{0}\\{1}{2}", tempDirectory, file.Name, cipher.Decrypt(archiveExtension));

            if (!File.Exists(name))
            {
                return(false);
            }
            if (File.Exists(file.Name))
            {
                File.Delete(file.Name);
            }
            ZipFile.ExtractToDirectory(name, ".\\");
            return(HashFile.GetMD5(file.Name) == file.Hash);
        }
예제 #2
0
        static void ReadFiles()
        {
            Trace.WriteLine("Ulaz u metodu ReadFiles");
            sizeFiles   = 0;
            numberFiles = 0;

            Trace.TraceInformation("ReadFiles(); Ukupno datoteka za procitat {0}", dataFileList.Count);
            foreach (ColumbiaFile file in dataFileList)
            {
                Trace.TraceInformation("Provjera hash vrijednosti za fajl: {0}", file.Name);
                if (HashFile.GetMD5(file.Name) != file.Hash)
                {
                    numberFiles++;
                    sizeFiles += file.Size;
                    updateFileList.Add(new ColumbiaFile(file.Name, file.Hash, file.Size));
                    Trace.TraceInformation("Hash vrijednost za datotku {0} nije ispravna.", file.Name);
                    Trace.TraceInformation("Hash datoteke: {0}; Hash baze: {1}", file.Hash, HashFile.GetMD5(file.Name));
                }
            }
            //poruka nakon zavrsene provjere
            Write("OK");
        }
예제 #3
0
        static bool CheckFiles()
        {
            numberFiles   = 0;
            errorFileList = new List <ColumbiaFile>();

            foreach (ColumbiaFile file in dataFileList)
            {
                if (HashFile.GetMD5(file.Name) != file.Hash)
                {
                    numberFiles++;
                    errorFileList.Add(new ColumbiaFile(file.Name, file.Hash, file.Size));
                }
            }

            if (numberFiles == 0)
            {
                Write("OK");
                return(true);
            }

            MessageError();
            return(false);
        }