read files in target dir on postback

2 posts, 0 answers
  1. Doug
    Doug avatar
    4 posts
    Member since:
    Sep 2010

    Posted 27 Oct 2010 Link to this post

    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?
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 02 Nov 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top