public async Task CreateFileAsync(File file, CancellationToken cancellationToken) { try { using (var fileStream = file.FileStream) using (var outFile = System.IO.File.Create(Path.Combine(_options.Directory, file.Name))) { await fileStream.CopyToAsync(outFile, cancellationToken); } } catch (IOException) { throw; } }
public bool TryGetFileInfo(string filename, out File file) { var path = Path.Combine(_options.Directory, filename); var fileInfo = new FileInfo(path); if (fileInfo.Exists) { file = new File() { Name = fileInfo.Name, Size = fileInfo.Length, LastModifiedDate = fileInfo.LastWriteTime.ToString(), FileStream = null }; } else { file = null; } return(fileInfo.Exists); }
public FileResult(File file) { this.FileId = file.Id; this.Name = file.Name; this.LastModifiedTimestamp = LastModifiedTimestamp; }