Solved

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

Posted on 2004-09-19
5
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
hagipmc earned 35 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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