• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

Image.fromfile vb.net 2005

Dim newImage As Image = Image.FromFile("image.bmp")

On the above, where does the image.bmp need to be?  I have it in my bin folder and in one project it works and in the other I get the message it's not there?
3 Solutions
If you don't specify a path, I think it will default to the start up directory of the shortcut that the IDE was run from.  You are better off specifying the path.  When it's in the same folder as the EXE, I usually use:

Dim Path as string = System.AppDomain.CurrentDomain.BaseDirectory() & "image.bmp"

Dim newImage As Image = Image.FromFile(Path)
Fernando SotoCommented:
image.bmp needs to be a fully qualified path and file name so that it can be found.

For example
    Dim newImage As Image = Image.FromFile("C:\Program File\MyApp\image.bmp")

If this image will be located in same folder as your application ,then you will use Applicatio.StartupPath
Dim newImage As Image = Image.FromFile(Application.StartupPath & "\image.bmp")

Fernando SotoCommented:
Hi Bob;

I would like to see a resolution to this question because all three experts had basically the same solution. I would like to see a point split.

bergertimeAuthor Commented:
Sorry guys, I had moved on and forgot about this question being open.  I gave Paul the lions share since he was first to post and he gave a more detailed answer.  Again thanks to all who posted a solution.

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now