标题:怎么得到一个文件路径
只看楼主
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
 问题点数:0 回复次数:1 
怎么得到一个文件路径
例如在c盘picture文件夹下有个one.gif文件
现在怎么得到它的完整路径:c:\\picture\\one.gif
谢谢回复!!!!!!!!!!!
搜索更多相关主题的帖子: 路径 文件 
2008-03-18 14:45
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
得分:0 
private void button2_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog   folder=new FolderBrowserDialog();
            if(folder.ShowDialog()==DialogResult.OK)
            {
                string fileName=folder.SelectedPath;
                FindImg(new DirectoryInfo(fileName));
            }
            else
                return;

                
        }
        PictureBox[] FindImg(DirectoryInfo   info)
        {
            if(!info.Exists)
            {
                return null;
            }
            FileSystemInfo[] files = info.GetFileSystemInfos();
            PictureBox[] pc = new PictureBox[files.Length];
            int count=0;
            try
            {
                for(int i=0;i<files.Length;i++)
                {
                    FileInfo file=files[i] as FileInfo;
                    string[] strArr=file.FullName.Split('.');
                    if(strArr[strArr.Length-1]=="gif")
                    {
                        PictureBox pcture=new PictureBox();
                        pcture.Image=Image.FromFile(file.FullName);
                        pc[count]=pcture;
                        count++;
                    }
                }
            }
            catch(Exception er)
            {
                this.label1.Text=er.Message;
            }
            return pc;
        }
所有代码!
谢谢!
2008-03-18 14:53



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




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

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