示例#1
0
        /// <summary>
        /// Get Sub Folders in the Paths for Recursion
        /// </summary>
        /// <param name="sourcePath">Source Path</param>
        /// <param name="targetPath">Target Path</param>
        /// <param name="diffResult">Diff Result for Catching Exception</param>
        /// <param name="result">Result Album</param>
        /// <param name="recursive">Recurive Stack</param>
        private void getSubFoldersForRecursion(string sourcePath, string targetPath, DiffResult diffResult, Album result, Stack<DiffStackContent> recursive)
        {
            try
            {
                List<string> sourceFolders = getSubFoldersFromPath(sourcePath);
                List<string> targetFolders = getSubFoldersFromPath(targetPath);

                // Check ALL Folders: Recursively Check ALL Files Inside
                foreach (string sourceFolder in sourceFolders)
                {
                    string targetFolder = Album.combinePath(targetPath, getNameFromPath(sourceFolder));

                    // If Target Folder Exist: Recursively Check
                    if (targetFolders.Exists(delegate(string tempPath) { return tempPath.ToUpper() == targetFolder.ToUpper(); }))
                    {
                        // Recursion by pushing the folder into stack
                        DiffStackContent temp = new DiffStackContent();
                        temp.source = sourceFolder;
                        temp.target = targetFolder;

                        recursive.Push(temp);
                        //result = append(result, compare(sourceFolder, targetFolder));
                    }
                    // If Target Folder Doesn't Exist: Add Directly
                    else
                    {
                        result.add(new Album(getNameFromPath(sourceFolder), sourceFolder));
                    }
                }
            }
            catch (UnauthorizedAccessException uae)
            {
                // Record:
                diffResult.uaeThrown();
            }
        }
示例#2
0
        /// <summary>
        /// Compare(Diff) Files
        /// </summary>
        /// <param name="sourcePath">Source Path</param>
        /// <param name="targetPath">Target Path</param>
        /// <param name="diffResult">Diff Result to Catch Exception</param>
        /// <param name="result">Result Album</param>
        private void diffCompareFiles(string sourcePath, string targetPath, DiffResult diffResult, Album result)
        {
            try
            {
                // Get the Source Files, Target Files, Source Metadatas:
                List<string> sourceFiles = getFilesFromPath(sourcePath);   // S
                List<string> targetFiles = getFilesFromPath(targetPath);   // T

                // Check ALL Files:
                foreach (string sourceFile in sourceFiles)
                {
                    string targetFile = Album.combinePath(targetPath, getNameFromPath(sourceFile));

                    // Different Files: Move Source Files to Target Folder
                    //                  Move only Photo Files
                    if ((Video.isVideo(sourceFile) || Photo.isPhoto(sourceFile)) && different(sourceFile, targetFile, targetFiles))
                    {
                        //result.add(new Files(sourceFile));
                        Files tempFile = Files.getFilesObject(sourceFile);
                        if (tempFile != null)
                            result.add(tempFile);
                    }
                }
            }
            catch (Exception e)
            {
                diffResult.uaeThrown();
            }
        }