I'm currently trying to add all the filePaths of the pictures that I selected through an OpenFileDialog to a List<>. However, when I try to start the program only the path of the first file is added to the List multiple times.
This is the code I tried with
OpenFileDialog MyDialog = new OpenFileDialog();
MyDialog.Filter = "Picture (.jpg)|*jpg|Picture (.jpeg)|*.jpeg|Picture (.png)|*.png";
MyDialog.Multiselect = true;
if (MyDialog.ShowDialog() == true)
{
foreach (String file in MyDialog.FileNames)
{
string fullPath = MyDialog.FileName;
FileListe.Add(Convert.ToString(new BitmapImage(new Uri(fullPath))));
}
}
you have to do it like this. you are using MyDialog.FileName
instead of that you should use file
FileListe.Add(Convert.ToString(new BitmapImage(new Uri(file ))));