joe_pool_is
Contributor
In my C# Project, I have added a couple hundred images by "drag-n-drop"-ing them into to the Properties.Resources section. All of these images were in an "images" folder of my Project on my computer. Currently, the Solution Explorer displays all of these images in an "images" folder that it created after my "drag-n-drop" operation.
Now: How do I *get* these images for my code?
I have a PictureBox named "pbImage" on my main form that needs to display these at various times, but my call to GetManifestResourceStream() always returns null.
I am concerned that the string "imageName" may not be correct, but I can not seem to find the wording that C# is looking for.
Any ideas?
Now: How do I *get* these images for my code?
I have a PictureBox named "pbImage" on my main form that needs to display these at various times, but my call to GetManifestResourceStream() always returns null.
I am concerned that the string "imageName" may not be correct, but I can not seem to find the wording that C# is looking for.
Code:
private void Set_Image(String imageName)
{
Assembly gExe = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream gImage;
String[] name = gExe.GetManifestResourceNames();
String image = name[0] + "." + imageName;
gExe = System.Reflection.Assembly.GetExecutingAssembly();
try
{
gImage = gExe.GetManifestResourceStream(image); // returns null
pbImage.Image = Image.FromStream(gImage); // causes exception
}
catch (Exception ex)
{
Console.WriteLine("Exception Message: {0}", ex.Message);
}
}
Any ideas?