Esempio n. 1
0
        public Contr(DiscElement el)
        {
            this.el      = el;
            Name         = el.getName();
            Path         = el.Path;
            isFile       = el.isFile();
            CreationDate = el.creationDate;
            if (el is MyDirectory)
            {
                MyDirectory temp = (MyDirectory)el;
                Type = "<DIR>";
                Size = "";
                if (temp.isBack)
                {
                    Name         = "..";
                    Type         = "";
                    Size         = "";
                    CreationDate = null;
                }
            }

            else
            {
                MyFile temp = (MyFile)el;
                Type    = temp.extension;
                Size    = temp.size.ToString();
                IntSize = temp.size;
            }
        }
Esempio n. 2
0
        public List <DiscElement> GetSubElements()
        {
            List <DiscElement> elements = new List <DiscElement>();

            string[] dirs     = null;
            string[] files    = null;
            var      backPath = Path.Substring(0, Path.LastIndexOf(@"\"));

            if (backPath == "C:")
            {
                backPath = "C:\\";
            }

            try
            {
                dirs  = Directory.GetDirectories(Path);
                files = Directory.GetFiles(Path);
            }
            catch (System.UnauthorizedAccessException)
            {
                Path = backPath;
                throw new Exception("");
            }

            var backDir = new MyDirectory(backPath, true);

            if (backDir.Path != Path)
            {
                elements.Add(backDir);
            }

            foreach (var item in dirs)
            {
                elements.Add(new MyDirectory(item));
            }

            foreach (var item in files)
            {
                elements.Add(new MyFile(item));
            }
            return(elements);
        }
Esempio n. 3
0
        public Contr(DiscElement ele)
        {
            this.ele     = ele;
            Name         = ele.getName();
            Path         = ele.Path;
            isFile       = ele.isFile();
            CreationDate = ele.creationDate;
            if (ele is MyDirectory)
            {
                MyDirectory temp = (MyDirectory)ele;
                Type = "<DIR>";


                Size = "";
            }

            else
            {
                MyFile temp = (MyFile)ele;
                Type    = temp.extension;
                Size    = temp.size.ToString();
                IntSize = temp.size;
            }
        }