New to Telerik UI for WPF? Download free 30-day trial

Adding Files Programmatically

RadCloudUpload allows you to prepare files for upload in code using the AddFile method of the control. The method will create a new CloudUploadFile object and add it in the Items collection of the RadCloudUpload component, after a validation is performed.

The file object will also be included in the InvalidItems or ValidItems collection, depending on the validation result.

The AddFile method expects a file stream with the file that will be uploaded, along with a file name to indicate the name of the file to be saved. In addition, you can control whether the stream should be automatically closed after the upload finishes or not by passing true as the last parameter of the method (autoCloseStream).

Example 1: Add a file using the RadCloudUpload AddFile method

this.cloudUpload.AddFile(theNameOfTheFileToBeAdded, fileStream, true); 
Me.cloudUpload.AddFile(theNameOfTheFileToBeAdded, fileStream, True); 

See Also

In this article