I've been working with C# for a number of months now. I often have to extract resources in the programs I've been writing and felt I had a good handle on it. However, last night I need to extract a simple image resource but found my normal method of extracting using a byte array simply wasn't working.
After a bit of experimenting, I stumbled upon the answer.
- Add your image as a resource (Check out this link for more info).
- Now to extract your image, use the following line:
Properties.Resources.ImageName.Save("FullPathAndNameOfImage.jpg");
NOTE: You don't have to extract as .jpg. You can extract as .PNG or GIF. The important part is you have to give a full path to extract the image to, as well as the file type.
No comments:
Post a Comment