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

read files in target dir on postback

1 Answer 65 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 28 Oct 2010, 03:49 AM
I wish to read the files uploaded right after they are uploaded.
I tried to use _FileUploaded event but the files are not copied into the target directory until after this event ends.
I don't want two buttons for the user, one for copying the files to the target directory and the other to read the file.

Any sugestions?

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 02 Nov 2010, 02:27 PM
Hello Doug,

I suggest that you use the InputStream property of the UploadedFile object that is available in the FileUploaded event. It is a stream pointing to the uploaded file, and you can use it in order to  read the file.

void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
    {
        byte[] buffer = new byte[e.File.ContentLength];
        using (Stream str = e.File.InputStream)
        {
            str.Read(buffer, 0, e.File.ContentLength);
 
            // use the read bytes
        }
    }


Kind regards,
Genady Sergeev
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
Tags
AsyncUpload
Asked by
Doug
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or