Пример #1
0
        /// <summary> STATIC.
        /// Set the date/time for a single file/directory (This works on files and directories)
        /// Go through the list, skipping H,S,R files, and add all the file+date objects to the Confirmation List
        /// (Only adds to the confirm list, Form 2 (Confirm) will actually write changes).
        /// </summary>
        /// <param name="filePath">Full path to the file/directory</param>
        /// <param name="fileTime">Date/Time to set the file/directory</param>
        /// <param name="isDirectory">Is this a directory???</param>
        internal void AddONEFiletoConfirmList(string filePath, DateTime fileTime, bool isDirectory)
        {
            SkipOrAddFile(filePath, isDirectory);
            //Make a NameDateObj out of 1 filename; Check all 3 date properties, and only write a time on match
            var currentobject = new NameDateObj {
                Name = filePath, FileOrDirType = SharedHelper.Bool2Int(isDirectory)
            };

            // Set the Creation date/time if selected
            if (checkboxes.C)
            {
                currentobject.Created = fileTime;
            }
            // Set the Modified date/time is selected
            if (checkboxes.M)
            {
                currentobject.Modified = fileTime;
            }
            // Set the last access time if selected
            if (checkboxes.A)
            {
                currentobject.Accessed = fileTime;
            }

            FilestoConfirmList.Add(currentobject);
        }
 public NameDateObjListViewVMdl(NameDateQuick thing)
 {
     Name          = thing.PathName;
     FileOrDirType = SharedHelper.Bool2Int(Directory.Exists(thing.PathName));
     Created       = thing.Created;
     Modified      = thing.Modified;
     Accessed      = thing.Accessed;
 }
Пример #3
0
        /// <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);
            }
        }