# 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**

```C#
this.cloudUpload.AddFile("theNameOfTheFileToBeAdded", fileStream, true);
```

```VB.NET
Me.cloudUpload.AddFile(theNameOfTheFileToBeAdded, fileStream, True);
```

## See Also

* [Providers](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/providers)
* [CloudUploadFile](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/cloud-upload-file)
* [Validation](https://www.telerik.com/products/wpf/documentation/controls/radcloudupload/features/validation)
