I want to loop through files and always make sure its just one item in the array I am looping through
var files = Request.Form.Files;
var singleFile = files[0];
foreach (var file in singleFile)
{
}
I am getting the error foreach statement cannot operate on variables of type '?' because '?' does not contain a public definition for 'GetEnumerator'
How can I fix this ! Thanks
singleFilealready contains first item of the array.files[0]will always get the first item in the collection. If that's all you want you're done. You can't iterate that item because it is an item, not a collection.