Results 1 to 2 of 2

Thread: disposing system.image.fromfile() object

  1. #1

    Thread Starter
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316

    disposing system.image.fromfile() object

    OK, I am loading a jpg into a picture box using...
    Code:
    picturebox.image = image.fromfile("temp.jpg")
    I then clear the image...
    Code:
    picturebox.image = Nothing
    I now want to delete the file "temp.jpg" but I get an exception stating that the file is currently in use. Im guessing that the object created by system.image.fromfile() still has its grasp on the file I want to delete. How do I get it to let go. Disposing of the picturebox control doesn't help. I have no way of referencing the object created by the system, (or at least that I know of...) any ideas. Thanks.

    -scuz
    SCUZ

  2. #2

    Thread Starter
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    As I occasionally try to do to aid anyone looking for the same answer Ill post a reply to my own message. What I did wrong was I disposed of the picturebox control itself and then attempted to re-create it which wasn't helping. I didn't realize under the image proprety of the picturebox was another dispose method. Disposing of the image property solved my problem. After testing to make sure there was somthing to dispose of using if not (picturebox.image is nothing) then picturebox.image.dispose...
    SCUZ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width