PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Embedded resource question

Reply

Embedded resource question

 
Thread Tools Rate Thread
Old 27-12-2004, 10:03 AM   #1
Tomer
Guest
 
Posts: n/a
Default Embedded resource question


Hi,

I've a gif in my project inside one of its directories (for example: Graphics\Icons), its is compiled as embedded resource.

I can't get the gif's stream when calling the method:
Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif");
Where GUI is the assembly name, and Battery1.gif is the image name.

This line works fine when the image is in the root of the project.

How can I make it work from directories?



Tomer.

  Reply With Quote
Old 27-12-2004, 10:25 AM   #2
Sergey Bogdanov
Guest
 
Posts: n/a
Default Re: Embedded resource question

Assuming that your image is placed into directory "Graphics\Icons" to
retrieve this image you should write something like this:

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Graphics.Icons.Battery1.gif");

Since you have to explicitly set the full path to the image in you assembly.


Tomer wrote:
> Hi,
>
> I've a gif in my project inside one of its directories (for example:
> Graphics\Icons), its is compiled as embedded resource.
>
> I can't get the gif's stream when calling the method:
> Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif");
>
> Where GUI is the assembly name, and Battery1.gif is the image name.
>
> This line works fine when the image is in the root of the project.
>
> How can I make it work from directories?
>
>
>
> Tomer.
>



--
Best regards,
Sergey Bogdanov
  Reply With Quote
Old 27-12-2004, 10:40 AM   #3
Tomer
Guest
 
Posts: n/a
Default Re: Embedded resource question

Will it work with directories with embedded spaces, like "Status bar\Icons"?

Tomer.


"Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
news:uAUzBY$6EHA.3596@TK2MSFTNGP12.phx.gbl...
> Assuming that your image is placed into directory "Graphics\Icons" to
> retrieve this image you should write something like this:
>
>

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Graphics.Icon
s.Battery1.gif");
>
> Since you have to explicitly set the full path to the image in you

assembly.
>
>
> Tomer wrote:
> > Hi,
> >
> > I've a gif in my project inside one of its directories (for example:
> > Graphics\Icons), its is compiled as embedded resource.
> >
> > I can't get the gif's stream when calling the method:
> >

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif"
);
> >
> > Where GUI is the assembly name, and Battery1.gif is the image name.
> >
> > This line works fine when the image is in the root of the project.
> >
> > How can I make it work from directories?
> >
> >
> >
> > Tomer.
> >

>
>
> --
> Best regards,
> Sergey Bogdanov



  Reply With Quote
Old 27-12-2004, 11:19 AM   #4
Sergey Bogdanov
Guest
 
Posts: n/a
Default Re: Embedded resource question

A namespace can't contain whitespaces that's why you can't embed your
image into the directory with a space like "Status bar" but you can
rename it like "Status_Bar", "StatusBar" ...

Tomer wrote:
> Will it work with directories with embedded spaces, like "Status bar\Icons"?
>
> Tomer.
>
>
> "Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
> news:uAUzBY$6EHA.3596@TK2MSFTNGP12.phx.gbl...
>
>>Assuming that your image is placed into directory "Graphics\Icons" to
>>retrieve this image you should write something like this:
>>
>>

>
> Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Graphics.Icon
> s.Battery1.gif");
>
>>Since you have to explicitly set the full path to the image in you

>
> assembly.
>
>>
>>Tomer wrote:
>>
>>>Hi,
>>>
>>>I've a gif in my project inside one of its directories (for example:
>>>Graphics\Icons), its is compiled as embedded resource.
>>>
>>>I can't get the gif's stream when calling the method:
>>>

>
> Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif"
> );
>
>>>Where GUI is the assembly name, and Battery1.gif is the image name.
>>>
>>>This line works fine when the image is in the root of the project.
>>>
>>>How can I make it work from directories?
>>>
>>>
>>>
>>>Tomer.
>>>

>>
>>
>>--
>>Best regards,
>>Sergey Bogdanov

>
>
>



--
Best regards,
Sergey Bogdanov
  Reply With Quote
Old 27-12-2004, 11:26 AM   #5
Tomer
Guest
 
Posts: n/a
Default Re: Embedded resource question

Thanks a bunch!!!

Tomer.



"Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
news:epa1O2$6EHA.128@TK2MSFTNGP15.phx.gbl...
> A namespace can't contain whitespaces that's why you can't embed your
> image into the directory with a space like "Status bar" but you can
> rename it like "Status_Bar", "StatusBar" ...
>
> Tomer wrote:
> > Will it work with directories with embedded spaces, like "Status

bar\Icons"?
> >
> > Tomer.
> >
> >
> > "Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
> > news:uAUzBY$6EHA.3596@TK2MSFTNGP12.phx.gbl...
> >
> >>Assuming that your image is placed into directory "Graphics\Icons" to
> >>retrieve this image you should write something like this:
> >>
> >>

> >
> >

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Graphics.Icon
> > s.Battery1.gif");
> >
> >>Since you have to explicitly set the full path to the image in you

> >
> > assembly.
> >
> >>
> >>Tomer wrote:
> >>
> >>>Hi,
> >>>
> >>>I've a gif in my project inside one of its directories (for example:
> >>>Graphics\Icons), its is compiled as embedded resource.
> >>>
> >>>I can't get the gif's stream when calling the method:
> >>>

> >
> >

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif"
> > );
> >
> >>>Where GUI is the assembly name, and Battery1.gif is the image name.
> >>>
> >>>This line works fine when the image is in the root of the project.
> >>>
> >>>How can I make it work from directories?
> >>>
> >>>
> >>>
> >>>Tomer.
> >>>
> >>
> >>
> >>--
> >>Best regards,
> >>Sergey Bogdanov

> >
> >
> >

>
>
> --
> Best regards,
> Sergey Bogdanov



  Reply With Quote
Old 27-12-2004, 03:02 PM   #6
John Kendrick
Guest
 
Posts: n/a
Default Re: Embedded resource question

Actually you can place resources in folders with spaces like "Status bar".
When referencing this is code you substitute the space with an underscore
like "Status_bar" and Visual Studio does the rest.

"Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
news:epa1O2$6EHA.128@TK2MSFTNGP15.phx.gbl...
> A namespace can't contain whitespaces that's why you can't embed your
> image into the directory with a space like "Status bar" but you can
> rename it like "Status_Bar", "StatusBar" ...
>
> Tomer wrote:
> > Will it work with directories with embedded spaces, like "Status

bar\Icons"?
> >
> > Tomer.
> >
> >
> > "Sergey Bogdanov" <sergey.bogdanov@gmail.com> wrote in message
> > news:uAUzBY$6EHA.3596@TK2MSFTNGP12.phx.gbl...
> >
> >>Assuming that your image is placed into directory "Graphics\Icons" to
> >>retrieve this image you should write something like this:
> >>
> >>

> >
> >

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Graphics.Icon
> > s.Battery1.gif");
> >
> >>Since you have to explicitly set the full path to the image in you

> >
> > assembly.
> >
> >>
> >>Tomer wrote:
> >>
> >>>Hi,
> >>>
> >>>I've a gif in my project inside one of its directories (for example:
> >>>Graphics\Icons), its is compiled as embedded resource.
> >>>
> >>>I can't get the gif's stream when calling the method:
> >>>

> >
> >

Assembly.GetExecutingAssembly().GetManifestResourceStream("GUI.Battery1.gif"
> > );
> >
> >>>Where GUI is the assembly name, and Battery1.gif is the image name.
> >>>
> >>>This line works fine when the image is in the root of the project.
> >>>
> >>>How can I make it work from directories?
> >>>
> >>>
> >>>
> >>>Tomer.
> >>>
> >>
> >>
> >>--
> >>Best regards,
> >>Sergey Bogdanov

> >
> >
> >

>
>
> --
> Best regards,
> Sergey Bogdanov



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off