Beispiel #1
0
 public void SearchInSingleDirBySize(string filePath, long from, long to, AdvancedAttributes att, SizeAttributes si)
 {
     listView.BeginUpdate();
     foreach (string s in Directory.GetFiles(filePath))
     {
         f    = new FileInfo(s);
         size = f.Length;
         if (si.KB)
         {
             size /= 1000;
         }
         else if (si.MB)
         {
             size /= 1000 * 1000;
         }
         else if (si.GB)
         {
             size /= 1000 * 1000 * 1000;
         }
         if (att.PermissionBased)
         {
             if ((att.Hidden && (f.Attributes == FileAttributes.Hidden) && (size >= from && size <= to)) ||
                 (att.ReadOnly && (f.Attributes == FileAttributes.ReadOnly) && (size >= from && size <= to)) ||
                 (att.Archive && (f.Attributes == FileAttributes.Archive) && (size >= from && size <= to)) ||
                 (att.ReadOnly && att.Hidden && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden)) && (size >= from && size <= to)) ||
                 (att.ReadOnly && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Archive)) && (size >= from && size <= to)) ||
                 (att.Hidden && att.Archive && (f.Attributes == (FileAttributes.Hidden | FileAttributes.Archive)) && (size >= from && size <= to)) ||
                 (att.ReadOnly && att.Hidden && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive)) && (size >= from && size <= to)) ||
                 (!att.ReadOnly && !att.Hidden && !att.Archive && (f.Attributes == FileAttributes.Normal) && (size >= from && size <= to)))
             {
                 ic = Icon.ExtractAssociatedIcon(f.FullName);
                 if (!img1.Images.ContainsKey(f.Extension))
                 {
                     img1.Images.Add(f.Extension, ic);
                 }
                 lvt          = new ListViewItem("" + k++);
                 lvt.ImageKey = f.Extension;
                 lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                 listView.Items.Add(lvt);
             }
         }
         else
         {
             if (size >= from && size <= to)
             {
                 ic = Icon.ExtractAssociatedIcon(f.FullName);
                 if (!img1.Images.ContainsKey(f.Extension))
                 {
                     img1.Images.Add(f.Extension, ic);
                 }
                 lvt          = new ListViewItem("" + k++);
                 lvt.ImageKey = f.Extension;
                 lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                 listView.Items.Add(lvt);
             }
         }
     }
     listView.EndUpdate();
 }
Beispiel #2
0
        public void SearchInSingleDirByName(string filePath, AdvancedAttributes att)
        {
            try
            {
                listView.BeginUpdate();
                foreach (string s in Directory.GetFiles(filePath))
                {
                    f = new FileInfo(s);
                    if (att.PermissionBased)
                    {
                        if ((att.Hidden && (f.Attributes == FileAttributes.Hidden) && r.Match(f.Name).Success) ||
                            (att.ReadOnly && (f.Attributes == FileAttributes.ReadOnly) && r.Match(f.Name).Success) ||
                            (att.Archive && (f.Attributes == FileAttributes.Archive) && r.Match(f.Name).Success) ||
                            (att.ReadOnly && att.Hidden && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden)) && r.Match(f.Name).Success) ||
                            (att.ReadOnly && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Archive)) && r.Match(f.Name).Success) ||
                            (att.Hidden && att.Archive && (f.Attributes == (FileAttributes.Hidden | FileAttributes.Archive)) && r.Match(f.Name).Success) ||
                            (att.ReadOnly && att.Hidden && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive)) && r.Match(f.Name).Success) ||
                            (!att.ReadOnly && !att.Hidden && !att.Archive && (f.Attributes == FileAttributes.Normal) && r.Match(f.Name).Success))
                        {
                            ic = Icon.ExtractAssociatedIcon(f.FullName);

                            if (!img1.Images.ContainsKey(f.Extension))
                            {
                                img1.Images.Add(f.Extension, ic);
                            }
                            lvt          = new ListViewItem("" + k++);
                            lvt.ImageKey = f.Extension;
                            lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                            listView.Items.Add(lvt);
                        }
                    }
                    else
                    {
                        if (r.Match(f.Name).Success)
                        {
                            ic = Icon.ExtractAssociatedIcon(f.FullName);
                            if (!img1.Images.ContainsKey(f.Extension))
                            {
                                img1.Images.Add(f.Extension, ic);
                            }
                            lvt          = new ListViewItem("" + k++);
                            lvt.ImageKey = f.Extension;
                            lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                            listView.Items.Add(lvt);
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                listView.EndUpdate();
            }
        }
Beispiel #3
0
 public void SearchInSingleDirByWord(string filePath, AdvancedAttributes att)
 {
     listView.BeginUpdate();
     foreach (string s in Directory.GetFiles(filePath))
     {
         try
         {
             f = new FileInfo(s);
             if (IsFileEndingWithPreferredExtension(f))
             {
                 if (att.PermissionBased)
                 {
                     if ((att.Hidden && (f.Attributes == FileAttributes.Hidden) && CheckForWord(f)) ||
                         (att.ReadOnly && (f.Attributes == FileAttributes.ReadOnly) && CheckForWord(f)) ||
                         (att.Archive && (f.Attributes == FileAttributes.Archive) && CheckForWord(f)) ||
                         (att.ReadOnly && att.Hidden && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden)) && CheckForWord(f)) ||
                         (att.ReadOnly && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Archive)) && CheckForWord(f)) ||
                         (att.Hidden && att.Archive && (f.Attributes == (FileAttributes.Hidden | FileAttributes.Archive)) && CheckForWord(f)) ||
                         (att.ReadOnly && att.Hidden && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive)) && CheckForWord(f)) ||
                         (!att.ReadOnly && !att.Hidden && !att.Archive && (f.Attributes == FileAttributes.Normal) && CheckForWord(f)))
                     {
                         ic = Icon.ExtractAssociatedIcon(f.FullName);
                         if (!img1.Images.ContainsKey(f.Extension))
                         {
                             img1.Images.Add(f.Extension, ic);
                         }
                         lvt          = new ListViewItem("" + k++);
                         lvt.ImageKey = f.Extension;
                         lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                         listView.Items.Add(lvt);
                     }
                 }
                 else
                 {
                     if (CheckForWord(f))
                     {
                         ic = Icon.ExtractAssociatedIcon(f.FullName);
                         if (!img1.Images.ContainsKey(f.Extension))
                         {
                             img1.Images.Add(f.Extension, ic);
                         }
                         lvt          = new ListViewItem("" + k++);
                         lvt.ImageKey = f.Extension;
                         lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                         listView.Items.Add(lvt);
                     }
                 }
             }
         }
         catch (Exception e) { MessageBox.Show(e.Message + "  " + e.StackTrace); }
     }
     listView.EndUpdate();
 }
Beispiel #4
0
        public void SearchInSingleDirByDate(string filePath, DateTime from, DateTime to, AdvancedAttributes att, DateAttributes d)
        {
            listView.BeginUpdate();
            foreach (string s in Directory.GetFiles(filePath))
            {
                f = new FileInfo(s);
                if (d.Modified)
                {
                    t = f.LastWriteTime;
                }
                else if (d.Accessed)
                {
                    t = f.LastAccessTime;
                }
                else if (d.Created)
                {
                    t = f.CreationTime;
                }
                if (att.PermissionBased)
                {
                    if ((att.Hidden && (f.Attributes == FileAttributes.Hidden) && CompareDates(from, t, to)) ||
                        (att.ReadOnly && (f.Attributes == FileAttributes.ReadOnly) && CompareDates(from, t, to)) ||
                        (att.Archive && (f.Attributes == FileAttributes.Archive) && CompareDates(from, t, to)) ||
                        (att.ReadOnly && att.Hidden && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden)) && CompareDates(from, t, to)) ||
                        (att.ReadOnly && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Archive)) && CompareDates(from, t, to)) ||
                        (att.Hidden && att.Archive && (f.Attributes == (FileAttributes.Hidden | FileAttributes.Archive)) && CompareDates(from, t, to)) ||
                        (att.ReadOnly && att.Hidden && att.Archive && (f.Attributes == (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive)) && CompareDates(from, t, to)) ||
                        (!att.ReadOnly && !att.Hidden && !att.Archive && (f.Attributes == FileAttributes.Normal) && CompareDates(from, t, to)))
                    {
                        ic = Icon.ExtractAssociatedIcon(f.FullName);
                        if (!img1.Images.ContainsKey(f.Extension))
                        {
                            img1.Images.Add(f.Extension, ic);
                        }
                        lvt          = new ListViewItem("" + k++);
                        lvt.ImageKey = f.Extension;
                        lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                        listView.Items.Add(lvt);
                    }
                }
                else
                {
                    if (CompareDates(from, t, to))
                    {
                        ic = Icon.ExtractAssociatedIcon(f.FullName);
                        if (!img1.Images.ContainsKey(f.Extension))
                        {
                            img1.Images.Add(f.Extension, ic);
                        }
                        lvt          = new ListViewItem("" + k++);
                        lvt.ImageKey = f.Extension;
                        lvt.SubItems.AddRange(new String[] { f.Name, f.FullName, "" + f.Length, f.Extension });
                        listView.Items.Add(lvt);
                    }
                }
            }

            listView.EndUpdate();
        }