Results 1 to 5 of 5

Thread: [RESOLVED] [2005] File is used by Another Program

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] [2005] File is used by Another Program

    Dear All,
    I have loaded a Image in a Imagebox from a localpath.Now I want to delete the image from the physical location.I am getting an error message that
    "the file is used by another window".How to rectify this problem.
    I am trying to delelte file as
    VB Code:
    1. My.Computer.FileSystem.DeleteFile(tempFile & "." & extension)
    How to clear the image from the Imagebox.

    Thanks in Advance,
    Dana
    Please mark you thread resolved using the Thread Tools as shown

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] File is used by Another Program

    How did you load the image?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] File is used by Another Program

    Thanks jmcilhinney
    VB Code:
    1. frmerrorpicture.pict_Error.Image = Image.FromFile(sc.tempFile & ".jpeg")
    Please mark you thread resolved using the Thread Tools as shown

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] File is used by Another Program

    From the MSDN help topic for the Image.FromFile method:
    The file remains locked until the Image is disposed.
    In .NET 2.0 call the Load method of the PictureBox, which doesn't lock the file.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [2005] File is used by Another Program

    Thanks jmcilhinney,
    It works like a charm.

    Dana
    Please mark you thread resolved using the Thread Tools as shown

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