Solved

Create and Delete image

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

19 Experts available now in Live!

Get 1:1 Help Now