/// <summary> /// Mode 3: Process One directory, Process 2nd Dir. with recursive sub-directory support. Calls SetFileDateTime() /// (Only adds to the confirm list, Form 2 will actually write changes). /// </summary> /// <param name="targetPath">Full path to the targetPath directory</param> /// <param name="comparePath">Full path to the comparePath directory</param> /// req, checkBox_Recurse.Checked, checkBoxShouldFiles.Checked internal void RecurseSubDirectoryMode3(string targetPath, string comparePath) { //no point continuing if we have nothing matching to compare to. if (!Directory.Exists(comparePath)) { return; } if (!comparePath.EndsWith(SharedHelper.SeperatorString)) { comparePath += SharedHelper.Seperator; } // Take a snapshot of the paths of the file system. Makes an IEnumerable. IEnumerable <string> destFileList = GetFilesAndDirsSafely(targetPath, "*", true); IEnumerable <string> srcFileList = GetFilesAndDirsSafely(comparePath, "*", true); // Find the common files. It produces a sequence and doesn't execute until the foreach statement. IEnumerable <string> queryCommonFiles = srcFileList.Intersect(destFileList, SharedHelper.explorerStringEqualityComparer(targetPath, comparePath)); foreach (string f in queryCommonFiles) { NameDateQuick srcfiletime = GetCmaTimesFromFilesystem(f); string nameChanged = f.Replace(comparePath, targetPath); bool isDirectory = Directory.Exists(nameChanged); SkipOrAddFile(nameChanged, isDirectory); var currentobject = new NameDateObjListViewVMdl(srcfiletime) { Name = nameChanged, FileOrDirType = SharedHelper.Bool2Int(isDirectory) }; //If Checkbox is selected: writes each time time to the date attribute that was radiobutton selected. StoreDateByCMACheckboxes(currentobject); var item = new NameDateObj(currentobject.Converter()); FilestoConfirmList.Add(item); } }
/// <summary> /// Display the date and time of the selected file (also works on Directories) /// </summary> public static NameDateQuick GetCmaTimesFromFilesystem(string pathName) { NameDateQuick cma; if (pathName != "") { cma = new NameDateQuick { PathName = pathName, Created = File.GetCreationTime(pathName).ToString(CultureInfo.CurrentCulture), Modified = File.GetLastWriteTime(pathName).ToString(CultureInfo.CurrentCulture), Accessed = File.GetLastAccessTime(pathName).ToString(CultureInfo.CurrentCulture), HiddenPathName = pathName, Selected = true }; } else { // Maybe no file/directory is selected // Then Blank out the display of date/time. cma = new NameDateQuick(); } return(cma); }