Is it possible to get byte[]
from FileResult
in C#?
Is it possible to get byte[] from FileResult?
Asked Answered
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;
}
FWIW for the sake of code clarity, i think an explicit cast would be preferred in this situation as you'd prefer an
InvalidCastException
over a NullReferenceException
. –
Dermatophyte @YuvalItzchakov I'd like think neither would be preferred :) –
Ihram
*FileContents instead –
Proclivity
© 2022 - 2024 — McMap. All rights reserved.
FileResult
is the wrong type to use. – Unsuccessful