Skip to main content
All docs
V24.1

IFileInputSelectedFile.Size Property

Returns the file size in bytes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

decimal Size { get; }

Property Value

Type Description
Decimal

The file size in bytes.

Remarks

The following example validates sizes of uploaded files:

<DxFileInput MaxFileSize="MaxValidFileSize" FilesUploading="OnFilesUploading" />

@code {
    const long MaxValidFileSize = 4_000_000;

    async Task OnFilesUploading(FilesUploadingEventArgs args) {
        foreach (var file in args.Files) {
            if (file.Size <= MaxValidFileSize) {
                /* 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);
            }
        }
    }
}
See Also