static void Main(string[] args)
        {
            var pdfFile  = new File("example.pdf");
            var jpegFile = new File("shot.jpeg");
            var docxFile = new File("1.docx");

            var myComputer = new Directory("my computer");

            myComputer.Add(pdfFile);

            var myDocuments = new Directory("my documents");

            myDocuments.Add(jpegFile);
            myDocuments.Add(docxFile);

            myComputer.Add(myDocuments);

            myComputer.Display(1);

            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the path of the directory:");
            string    path = Console.ReadLine();
            Component root = new Directory(path);

            root.Display(0);
            DirectoryInfo d = new DirectoryInfo(path);

            FileInfo[] files = d.GetFiles();
            foreach (FileInfo item in files)
            {
            }
            //root.Add(new File("File A"));
            //root.Add(new File("File B"));

            //Component comp = new Directory("Folder X");

            //comp.Add(new File("File XA"));
            //comp.Add(new File("File XB"));
            //root.Add(comp);

            //Component comp2 = new Directory("Folder Y");

            //comp2.Add(new File("File YA"));
            //comp2.Add(new File("File YB"));

            //Component comp3 = new Directory("Folder Z");
            //comp3.Add(new File("File YZA"));
            //comp3.Add(new File("File YZB"));
            //comp2.Add(comp3);

            //root.Add(comp2);

            //root.Add(new File("File C"));

            //File leaf = new File("File D");
            //root.Add(leaf);
            //root.Display(0);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Component root = new Directory("root");

            root.Add(new File("File A"));
            root.Add(new File("File B"));

            Component comp = new Directory("Folder X");

            comp.Add(new File("File XA"));
            comp.Add(new File("File XB"));

            root.Add(comp);

            Component comp2 = new Directory("Folder Y");

            comp2.Add(new File("File YA"));
            comp2.Add(new File("File YB"));

            Component comp3 = new Directory("Folder Z");

            comp3.Add(new File("File YZA"));
            comp3.Add(new File("File YZB"));

            comp2.Add(comp3);

            root.Add(comp2);

            root.Add(new File("File C"));

            File leaf = new File("File D");

            root.Add(leaf);

            root.Display();
        }