• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • 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 SotoRetiredCommented:
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 SotoRetiredCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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