I have a folder which contains all images.I want the names of the images to be displayed in a combobox and when i click on a image the image should be displayed in a picturebox(in C#.net).plzz help me in the code

String[] paths = {"D:\\Project\\Flower-02-KayEss-1.jpg", "D:\\Project\\My Pictures\\123.png" };
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("Flower");
            comboBox1.Items.Add("Table");
            comboBox1.Text = "Select";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            pictureBox1.Image = new Bitmap(paths[comboBox1.SelectedIndex]);
        }

More detailed version

String[] paths; 
        private void Form1_Load(object sender, EventArgs e)
        {
            DirectoryInfo di = new DirectoryInfo(@"D:\Project\Pictures\");
            paths = new String[di.GetFiles().Count()];
            MessageBox.Show(paths.Length + "");
            int i = 0;
            foreach (FileInfo fi in di.GetFiles())
            {
                comboBox1.Items.Add(fi.Name);
            }
            foreach (FileInfo fi in di.GetFiles())
            {
                paths[i] = fi.FullName;
                i++;
            }

            comboBox1.Text = "Select";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           pictureBox1.Image = new Bitmap(paths[comboBox1.SelectedIndex]);

        }

I tried this code but i am getting errors
I am new to C#.plzz help me.The errors are:

Error 1 The type or namespace name 'DirectoryInfo' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'FileInfo' could not be found (are you missing a using directive or an assembly reference?)

More detailed version

String[] paths; 
        private void Form1_Load(object sender, EventArgs e)
        {
            DirectoryInfo di = new DirectoryInfo(@"D:\Project\Pictures\");
            paths = new String[di.GetFiles().Count()];
            MessageBox.Show(paths.Length + "");
            int i = 0;
            foreach (FileInfo fi in di.GetFiles())
            {
                comboBox1.Items.Add(fi.Name);
            }
            foreach (FileInfo fi in di.GetFiles())
            {
                paths[i] = fi.FullName;
                i++;
            }

            comboBox1.Text = "Select";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           pictureBox1.Image = new Bitmap(paths[comboBox1.SelectedIndex]);

        }

I tried this code but i am getting errors
I am new to C#.plzz help me.The errors are:

Error 1 The type or namespace name 'DirectoryInfo' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'FileInfo' could not be found (are you missing a using directive or an assembly reference?)

This article has been dead for over six months. Start a new discussion instead.