How do I display an image in a picturebox using a variable name?

string name = "photo.jpg";

pictureBox1.ImageLocation = name;

// or

Image image = Image.FromFile(name);
pictureBox1.Image = new Bitmap(image);

neither is working. I'm getting the small box with an x in it.

Any help? Thanks

sorry, I figured out what I did wrong. I was using an array and I had the wrong index.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.