コード例 #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;
     }
 }
コード例 #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);
        }
コード例 #3
0
ファイル: FileResult.cs プロジェクト: jklemmack/FileManager
 public FileResult(File file)
 {
     this.FileId = file.Id;
     this.Name = file.Name;
     this.LastModifiedTimestamp = LastModifiedTimestamp;
 }