Hello everybody!
So as i wrote in subject, i need to cut the path from the filename's in array.
I got two listboxes and i read and compare data from the first and second and write it to third.In the listBox1 are filename's only and in listBox2 are filename's with path's.
The problem is how to cut the path from listBox2 array?
I got something like this C:\Documents and Settings\My Documents\My Pictures\mypicture.jpg and i need only mypicture.jpg.
The idea is to cut the string on the last backslash but i don't know which method is the best.
The code is here:
private void button1_Click(object sender, System.EventArgs e)
{
for (int j = 0; j < listBox1.SelectedItems.Count; j++)
for (int z = 0; z < listBox2.SelectedItems.Count; z++)
if ((listBox2.SelectedItems[j].ToString()) == listBox1.SelectedItems[z].ToString())
{
listBox3.Items.Add(listBox1.SelectedItems[z]);
}
}
Thank's for help!
Regards!
Miroslav
So as i wrote in subject, i need to cut the path from the filename's in array.
I got two listboxes and i read and compare data from the first and second and write it to third.In the listBox1 are filename's only and in listBox2 are filename's with path's.
The problem is how to cut the path from listBox2 array?
I got something like this C:\Documents and Settings\My Documents\My Pictures\mypicture.jpg and i need only mypicture.jpg.
The idea is to cut the string on the last backslash but i don't know which method is the best.
The code is here:
private void button1_Click(object sender, System.EventArgs e)
{
for (int j = 0; j < listBox1.SelectedItems.Count; j++)
for (int z = 0; z < listBox2.SelectedItems.Count; z++)
if ((listBox2.SelectedItems[j].ToString()) == listBox1.SelectedItems[z].ToString())
{
listBox3.Items.Add(listBox1.SelectedItems[z]);
}
}
Thank's for help!
Regards!
Miroslav