- private byte[] ConvertToBytes(IFormFile image)
- {
- byte[] imageBytes = null;
- //Then, Read stream in Binary
- BinaryReader reader = new BinaryReader(image.InputStream);
- imageBytes = reader.ReadBytes((int) image.ContentLength);
- return imageBytes;
- }
Do you know what happen to InputStream and ContentLength? In the IFormFile, are available of OpenReadStream and Length. I don't know how to use it. Do anyone know how to use it. I would like to have similar code as below example:
- private byte[] ConvertToBytes(IFormFile image)
- {
- byte[] imageBytes = null;
- //Then, Read stream in Binary
- BinaryReader reader = new BinaryReader(image.OpenReadStream());
- imageBytes = reader.ReadBytes((int) image.Length);
- return imageBytes;
- }
and the Message=Object reference not set to an instance of an object.:
- private byte[] ConvertToBytes(IFormFile image)
- {
- byte[] imageBytes = null;
- //Then, Read stream in Binary
- BinaryReader reader = new BinaryReader(image.OpenReadStream());
- imageBytes = reader.ReadBytes((int) image.Length);
- return imageBytes;
- }
Afzaal Ahmad ZeeshanPosted Apr 4, 2016, 1:35 AM