using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace file1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
           DirectoryInfo source = new DirectoryInfo(textBox1.Text); //源文件夹
            DirectoryInfo destination = new DirectoryInfo(textBox2.Text); //目标文件夹
            if (!destination.Exists) //判断指定的目标目录是否存在
                destination.Create(); //若指定目标目录不存在,则创建目录
            foreach (FileInfo f in source.GetFiles()) //遍历源文件夹
            {
                f.CopyTo(destination.Fullname + "\\" + f.Name, true);
                label3.Text += f.Name + "  被复制\n";
            }
            label3.Text += "复制完成";
            
            
            
        }
    }
}

解决方案 »

  1.   

    “System.IO.DirectoryInfo”不包含“Fullname”的定义,并且找不到可接受类型为“System.IO.DirectoryInfo”的第一个参数的扩展方法“Fullname”(是否缺少 using 指令或程序集引用?)
      

  2.   

    获取文件夹的名字出错了。获取的是对象还是string?
      

  3.   


    FullName,注意大小写,你得name是首字母小写,应该大写
      

  4.   

    不知道两个textBox的值是怎么得到的,建议你用FolderBrowserDialog对话框或其他系统对话框