Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When trying to append a FormFile to a FormFile[] (array) the FormFile is null

I have a FormFile[] that when I try adding a non-null FormFile object to it the array does not show any values.

     FormFile[] fileArray = new FormFile[10];
     FormFile myFile = new FormFile( /*Excel File*/ );
     fileArray.Append(myFile);

myFile[0] = null

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you are using System.Linq.Append this will return an new array with the value added at the end.
If you do the following:

 FormFile[] fileArray = new FormFile[10];
 FormFile myFile = new FormFile( /*Excel File*/ );
 var newFileArray = fileArray.Append(myFile);

newFileArray[11] will contain myFile

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading