Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Open folder with listBox

$
0
0

Hi,

I want to open a image file in a folder with a listBox, but every folder has a different name. The folders name is A en the image name is A.jpg. 

When I click A in listBox1 i want to open folder A and open A.jpg and when I click B i Want to open folder B and open B.jpg.

My code

My code:

private void listBox1_MouseClick(object sender, MouseEventArgs e)
        {
            string fileName = "C:\\Temp\\" + listBox1.SelectedItem + listBox1.SelectedItem + ".jpg";


            if (System.IO.File.Exists(fileName))
            {
                pictureBox1.Load(fileName);
            }
            
        }

The code won't work, can somebody help me?

Thanks!


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>