How to code image path relative to project

D

Dean Slindee

In order to deploy my app, I need to specify the following file path as
relative to my project. I need the image to be a file so that it can be
processed by the "DrawImageToScale" function so that the image is reduced in
size to a panel on the form.


Dim img As Image =
Image.FromFile("C:\Project\HumanServices\HumanServices\image\Contact.jpg")

Call DrawImageToScale(picModule1, img)

If this is not possible, is there a way to convert an embedded Resource
into a File or Stream?



Thanks,

Dean S
 
G

Guest

is

Image.FromFile(Application.StartupPath & "\Image\contact.jpg")

what your looking for?
 
M

Mythran

Dean Slindee said:
In order to deploy my app, I need to specify the following file path as
relative to my project. I need the image to be a file so that it can be
processed by the "DrawImageToScale" function so that the image is reduced
in size to a panel on the form.


Dim img As Image =
Image.FromFile("C:\Project\HumanServices\HumanServices\image\Contact.jpg")

Call DrawImageToScale(picModule1, img)

If this is not possible, is there a way to convert an embedded Resource
into a File or Stream?



Thanks,

Dean S

To get the embedded resource as a stream, you use Reflection. Look up the
GetManifestResourceStream method on the Assembly class :)

HTH,
Mythran
 
H

Herfried K. Wagner [MVP]

iwdu15 said:
Image.FromFile(Application.StartupPath & "\Image\contact.jpg")

what your looking for?

It's better to use 'Path.Combine' to concatenate the path with the file name
to prevent problems arising when the program is installed into the root
directory of the drive which may cause double backslashes to appear in the
combined path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top