Exemplo n.º 1
0
        private void srchbtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Treefile start = new Treefile(new DirectoryInfo(srchbox.Text));
                files.Clear();
                files.Add(start);

                //set the datacontext of our treeview to our list of tree files
                myTreeView.DataContext = files;
            }
            catch (System.ArgumentException)
            {
                MessageBox.Show("Your directory is not a valid format");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                MessageBox.Show("That directory was not found");
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("This program does not have access to all the files in this directory");
            }
            catch (System.IO.PathTooLongException)
            {
                MessageBox.Show("This filepath does meet the required length of < 260 characters");
            }
        }
Exemplo n.º 2
0
        private void srchbtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Treefile start = new Treefile(new DirectoryInfo(srchbox.Text));
                files.Clear();
                files.Add(start);

                //set the datacontext of our treeview to our list of tree files
                myTreeView.DataContext = files;
            }
            catch (System.ArgumentException)
            {
                MessageBox.Show("Your directory is not a valid format");
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                MessageBox.Show("That directory was not found");
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("This program does not have access to all the files in this directory");
            }
            catch (System.IO.PathTooLongException)
            {
                MessageBox.Show("This filepath does meet the required length of < 260 characters");
            }
        }
Exemplo n.º 3
0
            //constructor takes a directory and a parent and gets its size and name and creates a new treefile for all of its subdirectories
            // the parent is used to get the percent of parent parameter

            public Treefile(DirectoryInfo d, long parent)
            {
                Name                = d.Name;
                numberoffiles       = 0;
                numberofdirectories = 0;
                Size                = getSize(d);
                myDir               = d;
                this.parent         = parent;
                this.percentsize    = calculatepercent();
                foreach (var child in d.EnumerateDirectories())
                {
                    this.numberofdirectories += 1;
                    Treefile childtree = new Treefile(child, this.Size);
                    ChildDirectories.Add(childtree);
                }
                foreach (var c in myDir.EnumerateFiles())
                {
                    this.numberoffiles += 1;
                    Childfiles.Add(c);
                }
            }
Exemplo n.º 4
0
 //constructor takes a directory and gets its size and name and creates a new treefile for all of its subdirectories
 public Treefile(DirectoryInfo d)
 {
     Name = d.Name;
     Size = getSize(d);
     numberoffiles = 0;
     numberofdirectories = 0;
     myDir = d;
     parent = this.Size;
     this.percentsize = calculatepercent();
     foreach (var child in d.EnumerateDirectories())
     {
         this.numberofdirectories += 1;
         Treefile childtree = new Treefile(child, this.Size);
         ChildDirectories.Add(childtree);
     }
     foreach (var c in myDir.EnumerateFiles())
     {
         this.numberoffiles += 1;
         Childfiles.Add(c);
     }
 }