8

Is it possible to get byte[] from FileResult in C#?

NoWar
  • 36,338
  • 80
  • 323
  • 498
  • If you need the file bytes why not just read the file directly? `FileResult` is the wrong type to use. – asawyer Nov 13 '14 at 17:59
  • @asawyer Well I don't have access to that functionality. I have access to get FileResult only. – NoWar Nov 13 '14 at 18:07

1 Answers1

13

FileResult is an abstract class so that won't be the underlying instance type - assuming the correct overload is used then you should be able to cast it to a FileContentResult

if (result is FileContentResult data)
{
    var content = data.FileContents;
}
Wingjam
  • 742
  • 8
  • 17
James
  • 80,725
  • 18
  • 167
  • 237