How to add a file to a usercontrol's resources

  • Thread starter Thread starter Academia
  • Start date Start date
A

Academia

I want to include a help file with a usercontrol so that I can raise it with
the control's context menu.


I've been searching for how to do that and have concluded that the file can
be added as a resource but can find only examples of how to add other
things - usually strings.


1. Is that really the way I should do it?

2. Can you give of point to a sample code that adds a file to the resources?



Thanks
 
Academia said:
I want to include a help file with a usercontrol so that I can raise it with
the control's context menu.


I've been searching for how to do that and have concluded that the file can
be added as a resource but can find only examples of how to add other
things - usually strings.


1. Is that really the way I should do it?

2. Can you give of point to a sample code that adds a file to the resources?



Thanks

You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx
 
I thought "How nice, so simple once you learn how".

Then I realized that GetManifestResourceStream returns a stream and
Help.ShowHelp requires a file name!

Do I need to actually copy the resource into a temp file.


Thanks for the help.
 
I copied it to a temp file and it works OK.
Still wondering if all that is required.

Thanks for pointing out that site.
 
If you really need a file, then it is probably simpler and faster just to
package it with your application in an installer/deployment project. I did
not realize passing a stream for the help was not an option or I would have
pointed that out. Sorry!
 
I like your suggestion to use GetManifestResourceStream.
Making a temp file and passing it works well.

Thanks again
 
Back
Top