标题:如何显示不带路径的文件名
取消只看楼主
yuanwei568
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-11-20
结帖率:80%
 问题点数:0 回复次数:0 
如何显示不带路径的文件名
各位大侠:
    你们好,求助一个问题。我用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]);
                }
            
            }

        }
搜索更多相关主题的帖子: 路径 文件名 
2009-09-30 23:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-287358-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.380958 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved