|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
PictureboxReal 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,
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 ------------------ Show quoteHide quote "Paul Hadfield" <paul@nospamthankyoumam.com> wrote in message news:OTNwLPeVGHA.4864@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. > > Thanks Ken - perfect.
Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:ek%23uZtfVGHA.2276@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" <paul@nospamthankyoumam.com> wrote in message > news:OTNwLPeVGHA.4864@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. >> >> > >
Show quote
Hide quote
"Paul Hadfield" <paul@nospamthankyoumam.com> schrieb: Check out the code listings at > 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. <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/> 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 anEnglish 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/translate?hl=en&sl=de&u=http://dotnet.mvps.org/dotnet/code/graphics/&prev=/search%3Fq%3Dhttp://dotnet.mvps.org/dotnet/code/graphics/%26hl%3Den%26lr%3D Show quoteHide quote "Cerebrus" <zorg***@sify.com> wrote in message news:1144023058.288934.263720@t31g2000cwb.googlegroups.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" <zorg***@sify.com> schrieb: Sorry, but I currently do not plan an English translation. However, the >>> 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. ;-) 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/>
Is there a wrapping routine in the .NET Framework??
Download from web View a file in Hex Format function... Confused! Check Interface Implementation of a Type Which can i Select ASP.NET or VB.NET Unable to use Property instead of Sub in Thread Calculating Standard Deviation? Get a simple handler Last Position |
|||||||||||||||||||||||