Is it possible to export (save) images from the resource file at runtime? For example, if I use a set of images in my program, I have them in the resource file, but what if the user wants to be able to save that image and use it for other things... is it possible to put a "save image" button on a form for the user to save the image without me having to send them the image separately? Everything I have found in a search for this talks about the .resx file itself... I don't want to add/save/edit/update this file at runtime... I want to be able to export the files from it individually.
2 Answers
You can search inside your Assembly's Resources using the Assembly class:
Assembly.GetManifestResourceStream (YourResourceName)
Using this function you can retrieve the resource you need and save it with a FileStream.
Here some usefull links:

- 1
- 1

- 1,854
- 1
- 16
- 21
-
Thank you.... but... I am a self-taught programmer from way back in basic.... I have never used the Assembly class or the FileStream class... I can see and understand your Assembly class statement.... but... how do I then get this to the FileStream? – Hari_Seldon Jun 30 '16 at 16:29
-
Dear @Hari_Seldon I'll give you some documentation from whitch to start studing. – Babbillumpa Jul 01 '16 at 07:12
What you're going to want to do is find a SaveSileDialog control from the Dialogs group in your toolbox. Add it to your forms designer. This control will then appear in the bottom of your designer. Next add a Button (unless you've already done so).
Open the code of the button and add:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SaveFileDialog1.ShowDialog()
End Sub
This will open the SaveFileDialog we added earlier.
Open the code of the SaveFileDialog and add:
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
My.Resources.YourImageHere.Save(SaveFileDialog1.FileName, Drawing.Imaging.ImageFormat.YourFileTypeHere)
End Sub
Replace "YourImageHere" with the name of your resource, and replace "YourFileTypeHere" with the file type of your image(i.e. PNG, JPG, BMP, etc...). Documentation regarding a SaveFileDialog control can be found here on MSDN
Now your application should save the image when a user presses the button.

- 36
- 8