Esempio n. 1
0
        public bool VerifyChecksum()
        {
            uint previousChecksum = LastChecksum;

            LastChecksum = FileChecksum.Calculate(FullPath);
            return(LastChecksum != previousChecksum);
        }
Esempio n. 2
0
        public async Task SendFileAsync(FileTransferData data)
        {
            string futureFilePath = $"{(string.IsNullOrWhiteSpace(data.ControlSpace.Name) ? data.ControlSpace.ID.ToString() : data.ControlSpace.Name)}/{((data.Path != null) ? data.Path.Trim('/') + "/" : "")}";

            string fullFilename = futureFilePath + data.FileName;

            if (File.Exists(fullFilename))
            {
                if (data.Hash == FileChecksum.Calculate(fullFilename))
                {
#if DEBUG
                    Console.WriteLine($"File {data.Path}\\{data.FileName} already exist");
#endif
                    return;
                }
            }
            Directory.CreateDirectory(futureFilePath);
            File.WriteAllBytes(fullFilename, data.FileData);
#if DEBUG
            Console.WriteLine($"{data.Path}\\{data.FileName} transfered");
#endif
        }
Esempio n. 3
0
 public void ComputeHash()
 {
     Hash = FileChecksum.Calculate(FileData);
 }