有这样的函数嘛 或者比较好的方法 ,谢谢

解决方案 »

  1.   

    string sourceFileName = @"c:\a.txt";
                string destFileName = @"c:\a\a\a.txt";
                string destDir = Path.GetDirectoryName(destFileName);
                if (!Directory.Exists(destDir))
                {
                    Directory.CreateDirectory(destDir);
                }
                File.Copy(sourceFileName, destFileName);
      

  2.   

    自己定义一个吧            
    private void CopyFile()
    {
    string SourcePath = @"D:\temp\001\1.xml";
                string DescPath = @"e:\myData\001\1.xml";
    AutoCreateDirAndCopyFile(SourcePath,DescPath);
    }
    private void AutoCreateDirAndCopyFile(string SourcePath,string DescPath)
    {
                FileInfo fi = new FileInfo(DescPath);
                if (!Directory.Exists(fi.DirectoryName))
                {
                    Directory.CreateDirectory(fi.DirectoryName);
                }
                File.Copy(SourcePath, DescPath);
    }
      

  3.   

    FileSystemWatcher 类能实现同步复制。