views:

30

answers:

1

If i create an image with this method and then try to delete/modify the image file I get an error because there is a stream still using the file.

How can I delete or dispose of this stream so that I can work on the file?

+1  A: 

Do not use this method. Use FromStream instead and do this:

    Using FileStream = New IO.FileStream("D:\Test.jpg", IO.FileMode.Open)
        Dim x = System.Drawing.Image.FromStream(FileStream)

        'Do your image manipulation...'
    End Using

    IO.File.Delete("D:\Test.jpg")
diamandiev