How to access Images from Folder

Hi Experts,

I have created one project in C#. and I added one folder in this project which contain one Image file and I want to access this file in the project.
Can you tell me how to accesss this file.

Thanks in Advace.
Who is Participating?
neilpriceConnect With a Mentor Commented:
using System.Collections.Generic;


List<Bitmap> myImages = new List<Bitmap>();

//then to add images...

myImages.Add(new Bitmap("<your path>"));


then to refer to them in the order added to your list you can use myImages[x]

If you're getting a resource not found error then the path you're using is likely incorrect?  Which directory is the "Image" directory in?  Try copying the "Image" directory to the debug/bin path of your executable and see if that helps.

Hope this helps,
using System.Drawing;


Bitmap myBitmap = new Bitmap("<your path>");


Remember that <your path> is relative to the .exe that is generated by the compiler.

Hope this helps,
avinash_takaleAuthor Commented:
sorry, i tried this but it is not working.
I gave path like "Image\Test.gif" still it is not working.

It displays error like the resource not found.

And one more thing I want to create array of picture box just like in VB. Inthat we can add images and use by index.
How we can do in C#.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.