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

FileBytes

2 Answers 56 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 23 Feb 2010, 12:54 AM
We are using a virus checking service that accepts the filebytes from the file upload control as a parameter. How would I access this in the ItemCommand in the looping statement?

If I can't do it, is it possible to override the default upload control and use a regular file upload component?
RadFileExplorer explorer = sender as RadFileExplorer;  
foreach (UploadedFile file in explorer.Upload.UploadedFiles)  
{  
    bool bFileIsVirusFree = Helper.IsFileVirusFree(file.FileBytes);

2 Answers, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 25 Feb 2010, 11:07 AM
Hi Jim,

In your case you can use this approach:
protected void RadFileExplorer1_ItemCommand(object sender, RadFileExplorerEventArgs e)
{
    RadFileExplorer explorer = sender as RadFileExplorer;
    foreach (UploadedFile file in explorer.Upload.UploadedFiles)
    {
        byte[] fileBytes = new byte[file.ContentLength];
        file.InputStream.Read(fileBytes, 0, file.ContentLength);
        bool bFileIsVirusFree = Helper.IsFileVirusFree(fileBytes);
    }
}

I hope this helps.

Best wishes,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jim
Top achievements
Rank 1
answered on 02 Mar 2010, 12:03 AM
yep,
byte[] fileBytes = new byte[file.ContentLength];  
file.InputStream.Read(fileBytes, 0, file.ContentLength);  
 
I was not getting a correct result because of an unrelated serivice bug in our code. Thanks.
Tags
FileExplorer
Asked by
Jim
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Jim
Top achievements
Rank 1
Share this question
or