public void SaveFile(SaveFileParameter param) { Guid checksum; string path; if (!TryGetPath(param, out checksum, out path)) { return; } File.WriteAllBytes(path, param.FileData); var repository = new InfrastructureRepository(); repository.SaveFile(checksum.ToString(), param.FileName, path); }
static void _transfer_Completed(object sender, TransferEventArgs e) { var trans = (FileTransfer)sender; var header = JsonConvert.DeserializeObject <JsonHeader>(e.Config.State.ToString()); string sourceFilePath = string.Format(@"{0}{1}\{2}{3}", InfrastructureRepository.RootPath, trans.DirectoryPath, header.FileKey, Path.GetExtension(e.Config.FileName)); if (header.FileKey != CryptoManaged.MD5HashFile(sourceFilePath).ToString()) { File.Delete(sourceFilePath); return; } var repository = new InfrastructureRepository(); repository.SaveFile(header.FileKey, e.Config.FileName, sourceFilePath); }