如何显示不带路径的文件名
各位大侠:你们好,求助一个问题。我用openFileDialog打开了一些文件,但是在listBox1中显示的都带有路径的文件名,怎么样才能够把这些路径取消掉,不显示路径,直接显示文件名。谢谢各位了。我的代码如下
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{ int i;
Stream myStream;
// FileStream GetFile;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "D:\\岩性密度测井";
openFileDialog1.Filter = "txtfiles(*.txt)|*.txt|inp文件(*.inp)|*.inp|All files(*,*)|*.*";
openFileDialog1.FilterIndex=2;
openFileDialog1.Multiselect = true;
openFileDialog1.RestoreDirectory=true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{ myStream.Close(); }
string[] str1 =openFileDialog1.FileNames;
for (i = 0; i < str1.Length; i++)
{
listBox1.Items.Add(str1[i]);
}
}
}