Beispiel #1
0
 public void MoveTo(string destDir, MoveOperation operation)
 {
     if (!isDir)
     {
         WindowsFileSystemApi.MoveFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), MoveFileOptions.CopyAllowed | MoveFileOptions.ReplaceExisting, operation.MovedPieceOfFile);
     }
     else
     {
         MoveDirectory((DirectoryInfo)adapted, destDir, operation);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Moved directory with content to another place
        /// </summary>
        /// <param name="dir">Directory to move</param>
        /// <param name="destination">Destination path</param>
        /// <param name="operation">MoveOperation to report progress</param>
        private void MoveDirectory(DirectoryInfo dir, string destination, MoveOperation operation)
        {
            //TODO: Check if is WinAPI function for moving directories
            string moveDir = Path.Combine(destination, dir.Name);

            Directory.CreateDirectory(moveDir);

            foreach (FileInfo file in dir.GetFiles())
            {
                WindowsFileSystemApi.MoveFile(file, new FileInfo(Path.Combine(moveDir, file.Name)), MoveFileOptions.CopyAllowed, operation.MovedPieceOfFile);
            }

            foreach (DirectoryInfo di in dir.GetDirectories())
            {
                MoveDirectory(di, moveDir, operation);
            }

            dir.Delete(true);
        }