Solved

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

Posted on 2004-09-19
5
232 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

22 Experts available now in Live!

Get 1:1 Help Now