Solved

Create and Delete image

Posted on 2006-07-10
2
182 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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