Esempio n. 1
0
        void MoveDirectory(DirectoryInfoEx srcDir, DirectoryInfoEx destDir)
        {
            FileInfoEx[] files = srcDir.GetFiles();
            AddTotalCount(files.Length);
            foreach (FileInfoEx fi in files)
            {
                if (!Aborted)
                {
                    CheckPause();
                    AddCompletedCount(fi.FullName);
                    MoveFile(fi, destDir);
                }
            }
            files = null;

            DirectoryInfoEx[] dirs = srcDir.GetDirectories();
            AddTotalCount(dirs.Length);
            foreach (DirectoryInfoEx di in dirs)
            {
                if (!Aborted)
                {
                    CheckPause();
                    AddCompletedCount(di.FullName);
                    DirectoryInfoEx destSubDir = PrepateDirectoryForMove(di, destDir, di.Name);
                    if (destSubDir != null)
                    {
                        MoveDirectory(di, destSubDir);
                    }
                }
            }
            dirs = null;

            if (srcDir.Exists && srcDir.GetFileSystemInfos().Length == 0)
            {
                srcDir.Delete();
            }
        }
Esempio n. 2
0
        void MoveDirectory(DirectoryInfoEx srcDir, DirectoryInfoEx destDir)
        {
            FileInfoEx[] files = srcDir.GetFiles();
            AddTotalCount(files.Length);
            foreach (FileInfoEx fi in files)
                if (!Aborted)
                {
                    CheckPause();
                    AddCompletedCount(fi.FullName);
                    MoveFile(fi, destDir);
                }
            files = null;

            DirectoryInfoEx[] dirs = srcDir.GetDirectories();
            AddTotalCount(dirs.Length);
            foreach (DirectoryInfoEx di in dirs)
                if (!Aborted)
                {
                    CheckPause();
                    AddCompletedCount(di.FullName);
                    DirectoryInfoEx destSubDir = PrepateDirectoryForMove(di, destDir, di.Name);
                    if (destSubDir != null)
                        MoveDirectory(di, destSubDir);
                }
            dirs = null;

            if (srcDir.Exists && srcDir.GetFileSystemInfos().Length == 0)
                srcDir.Delete();
        }