I am trying to show files in a list so that they can be selected by the user.
The Append method on Items of type MultiSelectedList is throwing an error: 'Value cannot be null'.
Which value is null? The SelectListItem? Why is it null? It has values! Do I have to instantiate the 'Items' property?
public MultiSelectList Items { get; set; } = null!;private void ListUploadedFiles(){ var uploadPath = Path.Combine(Environment.ContentRootPath, "Upload"); if (Directory.Exists(uploadPath)) { DirectoryInfo di = new DirectoryInfo(uploadPath); savedFiles = di.GetFiles().ToList(); foreach (FileInfo file in savedFiles) { SelectListItem selectListItem = new SelectListItem(file.Name, file.Name,true); Items.Append(selectListItem); } }}