Ejemplo n.º 1
0
        private void OnCreate(MyFile file)
        {
            string path      = file.FullPath;
            int    situation = DefineDirectory(path);

            switch (situation)
            {
            case 1:
            {
                string newFileDir  = SwitchPathToAnotherDir(path, directoryPath1, directoryPath2);
                string newFilePath = Path.Combine(newFileDir, Path.GetFileName(path));
                MyFile newFile     = new MyFile(newFilePath);
                if (newFile.Exists)
                {
                    FileManager.Copy(path, newFileDir);
                }
                break;
            }

            case 2:
            {
                string newFileDir  = SwitchPathToAnotherDir(path, directoryPath2, directoryPath1);
                string newFilePath = Path.Combine(newFileDir, Path.GetFileName(path));
                MyFile newFile     = new MyFile(newFilePath);
                if (newFile.Exists)
                {
                    FileManager.Copy(path, newFileDir);
                }
                break;
            }
            }
        }
Ejemplo n.º 2
0
        private void MergeFolders(string path1, string path2)
        {
            MyFolder folder1 = new MyFolder(path1);

            if (!folder1.Exists)
            {
                folder1.DirectoryCreate();
            }
            MyFolder folder2 = new MyFolder(path2);

            if (!folder2.Exists)
            {
                folder2.DirectoryCreate();
            }
            var files1 = folder1.DirectoryGetFiles;
            var files2 = folder2.DirectoryGetFiles;

            foreach (var file in files1) //copying path1's files to path2
            {
                var fullPath = Path.Combine(path1, file.FullPath);
                FileManager.Copy(fullPath, path2);
            }
            foreach (var file in files2) //copying path2's files to path1
            {
                var fullPath = Path.Combine(path2, file.FullPath);
                FileManager.Copy(fullPath, path1);
            }
            var dirs1 = folder1.DirectoryGetFolders;
            var dirs2 = folder2.DirectoryGetFolders;

            foreach (var dir in dirs2) // creating folders from path2 in path1
            {
                var      dirFullPath1 = Path.Combine(path1, dir.Name);
                MyFolder dir1         = new MyFolder(dirFullPath1);
                dir1.DirectoryCreate();
                var dirFullPath2 = Path.Combine(path2, dir.FullPath);
                MergeFolders(dirFullPath1, dirFullPath2);
            }
            foreach (var dir in dirs1) // creating folders from path1 in path2
            {
                var      dirFullPath2 = Path.Combine(path1, dir.Name);
                MyFolder dir2         = new MyFolder(dirFullPath2);
                dir2.DirectoryCreate();
                var dirFullPath1 = Path.Combine(path2, dir.Name);
                MergeFolders(dirFullPath2, dirFullPath1);
            }
        }
Ejemplo n.º 3
0
 private void OnAskModelCopyEntries(List <Entry> entries)
 {
     FileManager.Copy(entries, directoryViewerSource.CurrentDirectory);
     ModelChange(GetArgs());
 }