4,826 questions
How to convert IFormFile to Byte array?
winanjaya
146
Reputation points
Hi
How to convert iFormFile to Byte array?, I have tried the below, but it keeps give me Cannot access a disposed object. Object name: 'FileBufferingReadStream
foreach (var formFile in supportingFiles)
{
long fileSize = formFile.Length;
string fileType = formFile.ContentType;
if (fileSize > 0)
{
using (var stream = new MemoryStream())
{
formFile.CopyTo(stream);
var bytes = stream.ToArray();
// do some stuffs
}
}
Developer technologies | ASP.NET | ASP.NET Core
Sign in to answer