I'm creating a RadUpload control in code when I try to change the stream for the file being uploaded I get the following exception. The stream gets uploaded but seems to be missing part of the contents. The initial file that is being added to ValidFiles is just there as a placeholder so that the FileUploadStarting event will fire.
The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Windows.Controls.RadUpload.OnFileUploadSizeChanged(Object sender, EventArgs e)
RadUpload upload =
new
RadUpload();
upload.TargetFolder =
"UserUploads"
;
upload.OverwriteExistingFiles =
true
;
upload.UploadServiceUrl =
"../FileUploadHandler.ashx"
;
upload.CurrentSession.ValidFiles.Add(file.Name,
new
RadUploadSelectedFile(file));
upload.FileUploadStarting +=
new
System.EventHandler<FileUploadStartingEventArgs>(upload_FileUploadStarting);
upload.UploadFinished +=
new
RoutedEventHandler(upload_UploadFinished);
upload.StartUpload();
void
upload_FileUploadStarting(
object
sender, FileUploadStartingEventArgs e)
{
e.NewFileStream = GetCsvStream();
}