• 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?
0
bergertime
Asked:
bergertime
3 Solutions
 
PaulHewsCommented:
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)
0
 
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")

Fernando
0
 
Priest04Commented:
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")

Goran
0
 
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.

Fernando
0
 
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.
0

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