How to access Images from Folder

Posted on 2006-05-30
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
    LVL 6

    Expert Comment

    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

    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#.

    LVL 6

    Accepted Solution

    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,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now