Home All Groups Group Topic Archive Search About

How to code image path relative to project

Author
10 Aug 2006 5:33 PM
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

Author
10 Aug 2006 5:50 PM
iwdu15
is

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

what your looking for?
--
-iwdu15
Author
10 Aug 2006 10:03 PM
Herfried K. Wagner [MVP]
"iwdu15" <jmmgoalsteratyahoodotcom> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Aug 2006 5:07 AM
Cor Ligthert [MVP]
Herfried,

Thank I will pay attention to that in future

Cor

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:OuZROjMvGHA.4688@TK2MSFTNGP06.phx.gbl...
> "iwdu15" <jmmgoalsteratyahoodotcom> schrieb:
>> 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.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
10 Aug 2006 6:02 PM
Mythran
Show quote Hide quote
"Dean Slindee" <slin***@charter.net> wrote in message
news:38KCg.281$NU3.35@newsfe04.lga...
> 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