Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public FileResult(File file)
 {
     this.FileId = file.Id;
     this.Name = file.Name;
     this.LastModifiedTimestamp = LastModifiedTimestamp;
 }