Hi Guys,
Real simple question here I'm sure. I'm trying to display a JPEG in a
picture box (VB.NET 2003).
pb.Image = Image.FromFile("C:\pic.jpg")
Then, later in the program I need to delete the image file from the disk.
pb.Image = Nothing
IO.File.Delete("C:\pic.jpg")
But I can't as the file is still open/in use. If I try to delete the image
file without displaying it in the picture box first it deletes fine, so I
know it's the picture box that's still got hold of the image file somehow.
What am I missing?
Cheers,
Paul. 6 1781
Hi,
Dim fs As New System.IO.FileStream("C:\bliss.jpg", IO.FileMode.Open)
Dim bm As New Bitmap(fs)
PictureBox1.Image = DirectCast(bm.Clone, Image)
fs.Close()
bm.Dispose()
System.IO.File.Delete("C:\bliss.jpg")
Ken
------------------
"Paul Hadfield" <pa**@nospamthankyoumam.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl... Hi Guys,
Real simple question here I'm sure. I'm trying to display a JPEG in a picture box (VB.NET 2003).
pb.Image = Image.FromFile("C:\pic.jpg")
Then, later in the program I need to delete the image file from the disk.
pb.Image = Nothing IO.File.Delete("C:\pic.jpg")
But I can't as the file is still open/in use. If I try to delete the image file without displaying it in the picture box first it deletes fine, so I know it's the picture box that's still got hold of the image file somehow.
What am I missing?
Cheers, Paul.
"Paul Hadfield" <pa**@nospamthankyoumam.com> schrieb: Real simple question here I'm sure. I'm trying to display a JPEG in a picture box (VB.NET 2003).
pb.Image = Image.FromFile("C:\pic.jpg")
Then, later in the program I need to delete the image file from the disk.
pb.Image = Nothing IO.File.Delete("C:\pic.jpg")
But I can't as the file is still open/in use. If I try to delete the image file without displaying it in the picture box first it deletes fine, so I know it's the picture box that's still got hold of the image file somehow.
Check out the code listings at
<URL:http://dotnet.mvps.org/dotnet/code/graphics/#ImageNoLock>.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thanks Ken - perfect.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ek****************@tk2msftngp13.phx.gbl... Hi,
Dim fs As New System.IO.FileStream("C:\bliss.jpg", IO.FileMode.Open)
Dim bm As New Bitmap(fs)
PictureBox1.Image = DirectCast(bm.Clone, Image)
fs.Close()
bm.Dispose()
System.IO.File.Delete("C:\bliss.jpg") Ken
------------------
"Paul Hadfield" <pa**@nospamthankyoumam.com> wrote in message news:OT**************@TK2MSFTNGP12.phx.gbl... Hi Guys,
Real simple question here I'm sure. I'm trying to display a JPEG in a picture box (VB.NET 2003).
pb.Image = Image.FromFile("C:\pic.jpg")
Then, later in the program I need to delete the image file from the disk.
pb.Image = Nothing IO.File.Delete("C:\pic.jpg")
But I can't as the file is still open/in use. If I try to delete the image file without displaying it in the picture box first it deletes fine, so I know it's the picture box that's still got hold of the image file somehow.
What am I missing?
Cheers, Paul.
Hi Herfried,
Herfried wrote : Check out the code listings at ...
I've been meaning to ask you this for some time now... Do you have an
English version of your site ? There's so much information there that I
would like to learn, but the language barrier ... ! I did do a course
in German language many years back, but my German is too rusty to be
able to understand technicalities. ;-)
Thanks,
Cerebrus.
Just go to google and put in the web address then click search. A seach
page should come up with a tranlate link. It's not perfect but it does the
job. http://translate.google.com/translat...l%3Den%26lr%3D
"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com... Hi Herfried,
Herfried wrote :
Check out the code listings at ...
I've been meaning to ask you this for some time now... Do you have an English version of your site ? There's so much information there that I would like to learn, but the language barrier ... ! I did do a course in German language many years back, but my German is too rusty to be able to understand technicalities. ;-)
Thanks,
Cerebrus.
"Cerebrus" <zo*****@sify.com> schrieb: Check out the code listings at ...
I've been meaning to ask you this for some time now... Do you have an English version of your site ? There's so much information there that I would like to learn, but the language barrier ... ! I did do a course in German language many years back, but my German is too rusty to be able to understand technicalities. ;-)
Sorry, but I currently do not plan an English translation. However, the
tips in the FAQ collection are available in English!
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: SamSpade |
last post by:
I have a usercontrol that contains a picturebox. The user can obtain
(creategraphics) a picturebox graphics object and draw on the picturebox.
She could do gr.GraphincInit.Millimeter and then draw...
|
by: akh |
last post by:
I want to use de Drag and Drop ´s event to move a picture box from a
form and within a Picture Box.
But I have behaviour if the MyPBox As PictureBox as the Globale
varible or not
Thanks for...
|
by: Tom |
last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to
stretched. I then load an image into that form and display it. As the user
moves the mouse over the form, I want to get and...
|
by: Mattbooty |
last post by:
Hello,
Not sure if anyone else has seen this bug, but I have a form where
the entire form is covered with a picturebox. The picturebox has a
mouseup event. I also have an open file dialog for...
|
by: Jerry West |
last post by:
I have a routine that updates a PictureBox image every x seconds. I do this
by first loading an array with the path to all of the images. I then
generate a random number to use as the index of the...
|
by: munibe |
last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small...
|
by: kirk |
last post by:
I have a form with a PictureBox control on it. The .Image property is
set to a PNG file(which shows the picture of the US map) with some
transparency in it. The .BackColor property is set to...
|
by: Jim McGivney |
last post by:
In C# on Form1 I genetate an array of PictureBoxes and populate each with an
image as seen in the code below.
Later on I want to access a specific PictureBox to change its image, but I
keep...
|
by: AWW |
last post by:
XP VB 2005 running an example from help that creates a picturebox in
code - the picturebox is not created.
If I comment out the "Dim Box as New PictureBox" and create it in
Design mode - the...
|
by: leshka82 |
last post by:
I have recently designed a Winform Image drag & drop utility. The approach I took was to have a Panel control serve as a destination for multiple file drop. Once the user dragged & dropped the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |