获取电脑磁盘中文件

来源:互联网 发布:shopex 源码 编辑:程序博客网 时间:2024/05/02 22:37

1.listview控件

private void button1_Click(object sender, EventArgs e)
        {
            dl.ShowDialog();
            String MyfilePath;
            String MyPathStr;
            String [] Myfile;
            MyfilePath = dl.FileName;
            MyPathStr = System.IO.Path.GetDirectoryName(MyfilePath);
            Myfile = System.IO.Directory.GetFiles(MyPathStr);
            int i = 0;
            while (true)
            {
                System.Windows.Forms.Application.DoEvents();
                try
                {
                    System.Drawing.Image Myimage;
                    Myimage = System.Drawing.Image.FromFile(Myfile[i]);
                    listView1.Items.Add(Myfile[i], i);
                    i += 1;
                  }
                catch (System.Exception)
                {
                    MessageBox.Show("出现错误");
                }
0 0
原创粉丝点击