Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-19
5
Medium Priority
?
240 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 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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