public void Handle(FileRequest message) { log.Info("Requested download file {1} of type {0}", message.Type, message.FileName); if (!string.IsNullOrEmpty(Path.GetDirectoryName(message.FileName))) throw new ArgumentException("FileName should be without path"); string fileTypeFolder = Path.Combine(this.expanderSharedFiles, message.Type.ToString()); Directory.CreateDirectory(fileTypeFolder); string filePath = Path.Combine(fileTypeFolder, message.FileName); if (!File.Exists(filePath)) { log.Warn("File {0} of type {1} doesn't exist", message.FileName, message.Type); SendMessage(new FileResponse { DownloadId = message.DownloadId, Size = 0 }); return; } var fi = new FileInfo(filePath); SendMessage(new FileResponse { DownloadId = message.DownloadId, Size = fi.Length, SignatureSha1 = CalculateSignatureSha1(filePath) }); }