Exemplo n.º 1
0
        /// <summary>
        /// Mode 2: Recursive.
        /// </summary>
        /// <param name="directoryPath">Path to start in.</param>
        internal void RecurseSubDirectoryMode2(string directoryPath)
        {
            NameDateObj timeInside = DecideWhichTimeMode2(directoryPath);

            SkipOrAddFile(directoryPath, true);

            //Make a NameDateObj out of 1 filename; writes each time time to the date attribute that was radiobutton selected.
            var currentobject = new NameDateObjListViewVMdl(timeInside)
            {
                Name = directoryPath, FileOrDirType = 1
            };

            StoreDateByCMACheckboxes(currentobject);

            var subFile = new NameDateObj(currentobject.Converter());

            FilestoConfirmList.Add(subFile);

            try
            {
                foreach (string subfolder in Directory.GetDirectories(directoryPath))
                {
                    RecurseSubDirectoryMode2(Path.Combine(directoryPath, subfolder));
                }
            }
            catch (UnauthorizedAccessException)
            { }
            catch (DirectoryNotFoundException)
            { }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Combine all the adjacent items which have the same name, and matching blank/nonblank or identical date attributes
 /// </summary>
 private void listView_condenseMultipleLinesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //first sort the list.
     listView1Confirm.BeginUpdate();
     //because it has to function on adjacent items, sort alphabetically first.
     listView1Confirm.ListViewItemSorter = new ExpLikeCmpHelperforListView();
     if (listView1Confirm.Items.Count >= 2)
     {
         for (var i = 0; i < listView1Confirm.Items.Count - 1; i++)
         {
             var thing1   = new NameDateObjListViewVMdl(listView1Confirm.Items[i]);
             var thing2   = new NameDateObjListViewVMdl(listView1Confirm.Items[i + 1]);
             var newthing = new NameDateObjListViewVMdl();
             //TODO: Pretty sure you are not supposed to do the following:
             if (newthing.Compare(thing1, thing2))
             {
                 listView1Confirm.Items.RemoveAt(i);
                 listView1Confirm.Items.RemoveAt(i);
                 listView1Confirm.Items.Add(newthing.Converter());
                 i--;
             }
         }
     }
     listView1Confirm.ListViewItemSorter = null;
     listView1Confirm.EndUpdate();
     UpdateStatusBar();
 }
Exemplo n.º 3
0
 private void StoreDateByCMACheckboxes(NameDateObjListViewVMdl currentobject)
 {
     //TODO: stop using N/A as a placeholder for logic
     //If Checkbox is selected:
     if (!checkboxes.C)
     {
         currentobject.Created = "N/A"; // Only Set the Creation date/time if selected
     }
     if (!checkboxes.M)
     {
         currentobject.Modified = "N/A"; // Only Set the Modified date/time if selected
     }
     if (!checkboxes.A)
     {
         currentobject.Accessed = "N/A"; // Only Set the Last Access date/time if selected
     }
 }
Exemplo n.º 4
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);
            }
        }