Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.
All docs
V24.1

IFileInputSelectedFile Interface

Contains information about the file and allows you to access file content.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

Declaration

public interface IFileInputSelectedFile

Remarks

The File Input component does not upload selected files automatically. Instead, the component raises the FilesUploading event once you or users start (or restart) an upload operation.

The Files argument of the FilesUploading event returns a collection of IFileInputSelectedFile objects. Use an object’s properties to get information about the file. Call the OpenReadStream method to read file content. Once the read operation is completed, you can send the file to another destination, save it to the file system, or display the file’s content on a web page.

The following example reads contents of uploaded files:

<DxFileInput FilesUploading="OnFilesUploading" />

@code {
    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (IFileInputSelectedFile file in args.Files) {
            try {
                /* The following code is intended for demonstration purposes only.
                Do not read a stream directly in memory to avoid performance and security-related issues. */
                using var stream = new System.IO.MemoryStream();
                await file.OpenReadStream(file.Size).CopyToAsync(stream);
            }
            catch (OperationCanceledException ex) {
                // Handle the cancel action here
            }
        }
    }
}
See Also