Back to Devexpress

IFileInputSelectedFile.Size Property

blazor-devexpress-dot-blazor-dot-ifileinputselectedfile-b979d2c0.md

latest1.5 KB
Original Source

IFileInputSelectedFile.Size Property

Returns the file size in bytes (an integer value).

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
decimal Size { get; }

Property Value

TypeDescription
Decimal

An integer value that specifies the file size in bytes.

|

Remarks

The following example validates sizes of uploaded files:

razor
<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

IFileInputSelectedFile Interface

IFileInputSelectedFile Members

DevExpress.Blazor Namespace