joe_pool_is Posted June 19, 2006 Posted June 19, 2006 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. 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? Quote Avoid Sears Home Improvement
Leaders snarfblam Posted June 19, 2006 Leaders Posted June 19, 2006 Assuming that you are using 2005, if the project has added them to the resources pseudo-folder for you, you should be able to access them like following: DefaultNamespace.Properties.Resources.ResourceName Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.