?
Solved

Load image, then unload it so I can delete it...

Posted on 2004-09-19
5
Medium Priority
?
242 Views
Last Modified: 2012-08-14
Hello

I want to load an image into an picturebox and after that I want to unload it so I can delete the image-file (cannot delete it while it is in the picturebox)

I tried to put picturebox.image = nothing but I still could not delete it...

Is there an other possibility to do that?

thanks

Sven
0
Comment
Question by:Svenrutten
2 Comments
 
LVL 1

Accepted Solution

by:
hagipmc earned 140 total points
ID: 12096283
Hi!

Sol 1:
  Create an ImageList control and add your images to the collection. This way your images are included in your resources files, so you can delete them anytime you want it. To get a pic from the imagelist control to a picturebox control you can use this code:

       ' Me.picBox.SizeMode = PictureBoxSizeMode.StretchImage
       Me.picBox.Image = Me.ImageList1.Images.Item(0)

The only problem is that in an imagelist control can store images no larger than 256x256, so this solution in no good for large images because they are resized to a max 256x256 format.


Sol2:
 Create a temporary image object , use it and then dispose it:

        Dim imgObj As Image
        imgObj = System.Drawing.Image.FromFile("C:\Images\Winter.jpg")
        Me.picBox.Image = New Bitmap(imgObj)
        imgObj.Dispose()

This is much better :)

Good luck!
0
 

Expert Comment

by:peichen
ID: 12114521

This should do it.  Change the "LocalPath" your image path and "Picture.jpg" as the Picture name


***********************************************************

<%@ Import Namespace="System.Web.UI.HtmlControls.HtmlInputFile" %>

File.Delete("C:\LocalPath\Picture.jpg")

***********************************************************
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses

850 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