示例#1
0
 public void CopyTo(string destDir, CopyOperation operation)
 {
     if (!isDir)
     {
         WindowsFileSystemApi.CopyFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), CopyFileOptions.None, operation.CopiedPieceOfFile);
     }
     else
     {
         CopyDirectory((DirectoryInfo)adapted, destDir, operation);
     }
 }
示例#2
0
        /// <summary>
        /// Copy directory
        /// </summary>
        /// <param name="dir">Directory to copy</param>
        /// <param name="destination">Destination directory</param>
        /// <param name="operation">CopyOperation to report changes</param>
        private void CopyDirectory(DirectoryInfo dir, string destination, CopyOperation operation)
        {
            string copyDir = Path.Combine(destination, dir.Name);

            Directory.CreateDirectory(copyDir);

            foreach (FileInfo file in dir.GetFiles())
            {
                WindowsFileSystemApi.CopyFile(file, new FileInfo(Path.Combine(copyDir, file.Name)), CopyFileOptions.None, operation.CopiedPieceOfFile);
            }

            foreach (DirectoryInfo di in dir.GetDirectories())
            {
                CopyDirectory(di, copyDir, operation);
            }
        }