guy said:
thanks Rakesh,
I was actually looking for a way of doing this using a designer,
ideally the ide if possible.
Binary resources are serialized and then base64 encoded before they are
put in a .resx file. You have two options.
- With the IDE you can add the icon to a form through its Icon property,
then open the .resx file as a text file, locate the entry and copy it to
the resx file where you *really* want the icon. Then you can remove the
value of the form's icon property.
- You can write some code to do this. The ResXResourceWriter will do the
serialization and encoding for you. For example, here code that will
read an icon file and write the serialised data into a .resx file:
// iconFile is the name of the .ico file
// iconName is the name of the element in the .resx file for the data
// resXName is the name of the .resx file that will be created
using (ResXResourceWriter writer = new ResXResourceWriter(resXName))
{
using(FileStream file = File.Open(iconFile, FileMode.Open))
{
Icon icon = new Icon(file);
writer.AddResource(iconName, icon);
writer.Generate(); // must do this after the last resource has been
added
}
}
Richard