C# asp.net 把一个文件夹下所有文件复制到另一个文件夹下  求代码   
在线等!随便看一下这个贴 我好结这个贴 http://topic.csdn.net/u/20101011/17/427dad67-9c19-45b1-82d7-b813fc24241e.html

解决方案 »

  1.   

    递归就可以搞定
     
    void CopyUpdateFile(string srcPath, string aimPath)
            {
                if (aimPath[aimPath.Length - 1] != Path.DirectorySeparatorChar)
                    aimPath += Path.DirectorySeparatorChar;
                if (!Directory.Exists(aimPath))
                    Directory.CreateDirectory(aimPath);
                if (!Directory.Exists(srcPath))
                    return;
                string[] fileList = Directory.GetFileSystemEntries(srcPath);            foreach (string file in fileList)
                {
                    int k = file.LastIndexOf("\\");
                    string filename = file.Substring(k + 1);
                    if (filename.ToLower() != Path.GetFileName(Application.ExecutablePath).ToLower())
                    {
                        if (Directory.Exists(file))
                            CopyUpdateFile(file, aimPath + Path.GetFileName(file));
                        else
                        {
                            try
                            {
                                File.Copy(file, aimPath + Path.GetFileName(file), true);
                                //File.Delete(file);
                            }
                            catch (Exception e)
                            {
                               Console.WriteLine("复制文件失败:" + file + e.Message);
                                continue;
                            }
                        }
                    }
                }
            }
      

  2.   

    上面是我以前写的一个函数,大概意思就是这样的 int k = file.LastIndexOf("\\");
                    string filename = file.Substring(k + 1);
                    if (filename.ToLower() != Path.GetFileName(Application.ExecutablePath).ToLower())把上面这几句去掉,对你没用,你不需要判断
      

  3.   

    System.IO.Directory.Copy("源目录","目标目录")
      

  4.   


    善用baidu
    http://www.cnblogs.com/c-delight/archive/2005/10/09/251126.html