public bool VerifyChecksum() { uint previousChecksum = LastChecksum; LastChecksum = FileChecksum.Calculate(FullPath); return(LastChecksum != previousChecksum); }
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 }
public void ComputeHash() { Hash = FileChecksum.Calculate(FileData); }