Try this:
public partial class Form1 : Form
{
string parentDir = "";
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string filename = System.IO.Path.Combine(parentDir, listBox1.SelectedItem.ToString());
pictureBox1.Image = Image.FromFile(filename);
}
private void selectFilesButton_Click(object sender, EventArgs e)
{
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Filter = "";
dlg.Title = "";
dlg.Multiselect = true;
DialogResult dr = dlg.ShowDialog(this);
if (dr == DialogResult.OK)
{
foreach (string file in dlg.FileNames)
{
if (string.IsNullOrEmpty(parentDir))
parentDir = System.IO.Path.GetDirectoryName(file);
listBox1.Items.Add(file);
}
}
}
}
}
hth Stoffy