How Can i Show preview image

Thread is closed for posting
5 posts, 0 answers
  1. aliguldur
    aliguldur avatar
    4 posts
    Member since:
    Oct 2004

    Posted 09 Jul 2010 Link to this post

    Hi,
    How Can i Show preview image when select file from dialogbox and then click button for save.
    i tried telerik 'change avatar ' examp it working for show but i cant save image. when i try save file always error
    '''' The process cannot access the file because it is being used by another process. '''
    My code below

    'show image with ajax

     


    Protected
    Sub AsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) Handles AsyncUpload1.FileUploaded

     

    Thumbnail.Width =

     

    Unit.Pixel(200)

     

    Thumbnail.Height =

     

    Unit.Pixel(150)

     

     

     

    Dim imageData As Byte() = New Byte(e.File.InputStream.Length) {}

     

    e.File.InputStream.Read(imageData, 0, e.File.InputStream.Length)

    Thumbnail.DataValue = imageData

     

     

    End Sub

     

    'save image

     


    Protected
    Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

     

     

     

        For Each f As Telerik.Web.UI.UploadedFile In AsyncUpload1.UploadedFiles

     

        f.SaveAs(

     

    "c:\a.jpg", True)

     

     

     

        Next

     

     

     

    End Sub

     


    thanks
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 14 Jul 2010 Link to this post

    Hi aliguldur,

    As we have already explained in the support thread, you need to wrap the FileStream inside using statement. This is example code:

    Protected Sub AsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As FileUploadedEventArgs)
                Thumbnail.Width = Unit.Pixel(200)
                Thumbnail.Height = Unit.Pixel(150)
     
                Dim imageData As Byte() = New Byte(e.File.InputStream.Length) {}
     
                Using stream As Stream = e.File.InputStream
                    stream.Read(imageData, 0, e.File.InputStream.Length)
                End Using
     
                Thumbnail.DataValue = imageData
     
            End Sub



    Greetings,
    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
  4. aliguldur
    aliguldur avatar
    4 posts
    Member since:
    Oct 2004

    Posted 14 Jul 2010 Link to this post

    i'm sorry it's not works
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 15 Jul 2010 Link to this post

    Hello aliguldur,

    Please paste here your current code so that we can take a look at it. This should have fixed the problem that you experience, however, there is a chance that in your case something else is going wrong.

    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
  6. majid
    majid avatar
    1 posts
    Member since:
    Dec 2010

    Posted 12 Jan 2011 Link to this post

    you have to close your file

    use  e.File.InputStream.close()
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017