This is a migrated thread and some comments may be shown as answers.

RadUpload - Casting UploadedFiles to FileInfo[] for Queuing

2 Answers 101 Views
Upload
This is a migrated thread and some comments may be shown as answers.
jay
Top achievements
Rank 1
jay asked on 18 Nov 2011, 08:17 PM
Hello,

I am trying to queue all my uploaded documents using RadUpload.
I can queue easily using Drag n Drop, however I am having difficulties casting the uploadedFiles from RadUpload to FileInfo[]. 
Sections of the working DragnDrop and the Not-working RadUpload are included below. 

How do I cast my UploadedFiles to FileInfo[] ???
Thank You.



private void ImageDrop_Drop(object sender, DragEventArgs e)
{
            // Queue the FileInfo objects representing dropped files
            files = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];
................................
}
 
private void RadUpload1_UploadFinished(object sender, RoutedEventArgs e)
{
             
            files = RadUpload1.CurrentSession.UploadedFiles as FileInfo[];
....................................
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 23 Nov 2011, 10:15 AM
Hi Jay,

The RadUpload1.CurrentSession.UploadedFiles collection is of type Collection<RadUploadSelectedFile> so each item in it is of type RadUploadSelectedFile and this is why you cannot cast it to a FileInfo type. But the RadUploadSelectedFile class exposes a File property of type FileInfo which you can use instead:
private void RadUpload1_UploadFinished(object sender, RoutedEventArgs e)
{
    var files = new List<FileInfo>();
    foreach (RadUploadSelectedFile uploadedFile in RadUpload1.CurrentSession.UploadedFiles)
    {
        files.Add(uploadedFile.File);
    }
}
Give this approach a try and let us know how it goes.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
jay
Top achievements
Rank 1
answered on 23 Nov 2011, 03:16 PM
Thanks for your feedback. I had stumbled onto this yesterday.
Tags
Upload
Asked by
jay
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
jay
Top achievements
Rank 1
Share this question
or