How to access Images from Folder

Posted on 2006-05-30
Medium Priority
Last Modified: 2010-04-16
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.
Question by:avinash_takale
  • 2

Expert Comment

ID: 16792630
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,

Author Comment

ID: 16792717
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#.


Accepted Solution

neilprice earned 400 total points
ID: 16792748
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,

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question