Solved

Create and Delete image

Posted on 2006-07-10
2
179 Views
Last Modified: 2010-04-23
Hi,
I am working on a vb.net windows application. (windows 2000 / .net 1.1)

The application dynamically creates a picturebox and loads a picture into it from disk. Then after a couple of seconds the app needs to delete it.
However, when I try to delete the file I get this error:

An unhandled exception of type 'System.IO.IOException' occurred in microsoft.visualbasic.dll
Additional information: The process cannot access the file "C:\test.Png" because it is being used by another process.

But the only process that could be using it is the app itself.
I've also tried this to no avail:
    pic1.Image=Nothing
    Controls.Remove(pic1)
    Kill("C:\test.Png")

Any ideas...?
0
Comment
Question by:gjok
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 17078247
The problem is the Image.FromFile locks the image, and you need to release resources.  You need to call the Dispose method to release resources.

Bob
0
 
LVL 2

Author Comment

by:gjok
ID: 17080811
Thanks that seems to have corrected the problem!

This may be related to a similar issue I have with the webbrowser control (AxSHDocVw.AXWebBrowser).
If you can help, please see:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21914977.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Limiting string to two deciamls 18 49
VB.Net - Oracle BulkCopy from CSV Date Format 7 44
Allow User To Arrange Columns At Datagridview 3 19
VS.net 2010 11 18
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now