I fill a list from OpenFileDialog
and I put it in "file" and then put it on the list like this:
foreach (string file in selectedFiles)
{
ListBoxItem lstItem = new ListBoxItem();
lstItem.Content = file; //File es la cadena de la URL
miLista.Items.Add(lstItem);
}
What I assign to ListBox
are URL
type
c: \ user \ paco \ imagen1.jpg
c: \ user \ paco \ image2.jpg
All right up to here, but now I need to go through that ListBox
and enter their items in a String[]
String[] matriz = new String[miLista.Items.Count];
foreach (Object index in miLista.Items)
{
matriz = index.ToString().Split();
}
In this way what gets me into each index of string[]
is the following:
System.Windows.Controls.ListBoxItem: c: \ user \ cucumber \ image1.jpg System.Windows.Controls.ListBoxItem: c: \ user \ cucumber \ image2.jpg System.Windows.Controls.ListBoxItem: c: \ user \ cucumber \ image3.jpg
What I need is only the URL
and that I do not return the Type and the Value, I need to put in the String[]
only the value.
I fill ListBox
like this:
OpenFileDialog myFD = new OpenFileDialog();
myFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
myFD.Multiselect = true;
myFD.Title = "Seleccione uno o más archivos";
myFD.Filter = "Archivos imagen (*.jpg),(*.jpeg),(*.gif),(*.png)|*.jpg;*.jpeg;*.gif;*.png";
Nullable<bool> result = myFD.ShowDialog();
if (result == true)
{
string[] selectedFiles = myFD.FileNames; // La propiedad FileNames (o FileName) almacena la ruta, nombre y extensión.
foreach (string file in selectedFiles)
{
miLista.Items.Add(file);
}
archivo.set_listaReproduccion(selectedFiles);
archivo.grabar();
}