ASPxFileManager.FileDownloading Event
Fires on the server side before a file download starts, and allows you to cancel the action.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Event Data
The FileDownloading event's data class is FileManagerFileDownloadingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the action that raised the event should be canceled. Inherited from FileManagerActionEventArgsBase. |
ErrorText | Gets or sets a text for the explanatory message. Inherited from FileManagerActionEventArgsBase. |
File | Gets a file related to the event. |
InputStream | Gets a stream object that points to the downloaded file. |
OutputStream | Set this property to change the original file content. |
Remarks
Each time a file is going to be downloaded on the server side, the FileDownloading event occurs, allowing you to cancel the action. You can use the event parameter’s FileManagerFileDownloadingEventArgs.File property to identify a file that is being processed. The FileManagerFileDownloadingEventArgs.InputStream and FileManagerFileDownloadingEventArgs.OutputStream properties allow you to modify a file, before sending it to the client side.
Important
The FileManagerFileDownloadingEventArgs.InputStream and FileManagerFileDownloadingEventArgs.OutputStream properties are not in effect for cloud providers and are set to null.
The example below demonstrates how you can use the FileDownloading server-side event to add a watermark to the downloaded image files.
protected void ASPxFileManager1_FileDownloading(object source, DevExpress.Web.FileManagerFileDownloadingEventArgs e) {
if (IsImageExtension(e.File.Extension))
e.OutputStream = AddWatermarkToImage(e.InputStream);
}
To cancel the download operation, set the FileManagerActionEventArgsBase.Cancel property to true
.