Пример #1
0
        private int GetFiles(bool ShowHidden, string DirectoryLocation)
        {
            //List Directies and gather information about each
            DirectoryInfo dirInfo = new DirectoryInfo(DirectoryLocation);

            DirectoryInfo[] dirs        = dirInfo.GetDirectories();
            int             countHidden = 0;

            FileInfo[] files = dirInfo.GetFiles();

            foreach (FileInfo file in files)
            {
                string attr = file.Attributes.ToString();

                if (attr.Contains("Hidden"))
                {
                    if (ShowHidden)
                    {
                        format.ConsoleColorWrite(file.Name, ConsoleColor.Yellow, false);
                    }
                    countHidden++;
                }
                else if (!attr.Contains("Hidden"))
                {
                    Console.WriteLine(file.Name);
                }
            }
            return(countHidden);
        }