示例#1
0
        private string create_random_file(string parent_directory)
        {
            string name = randomizer.NextFileName();
            string path = IO.Path.Combine(parent_directory, name);

            int size = _avg_file_size + randomizer.Next(-_file_size_delta, _file_size_delta + 1);

            using (IO.Stream file = IO.File.Create(path)) {
                byte[] buffer = new byte[1024];
                for (int pos = 0; pos < size; pos++)
                {
                    randomizer.NextBytes(buffer);
                    file.Write(buffer, 0, 1024);
                }
            }

            IO.FileAttributes attr = randomizer.NextAttributes(false);
            System.IO.File.SetAttributes(path, attr);

            Console.WriteLine("Created file " + path + " with attributes " + attr.ToString());
            entries.Add(new Entry(path, basepath));
            return(path);
        }
示例#2
0
        static void logType(System.IO.FileAttributes attributes, string fn, string addToEnd)
        {
            string att = attributes.ToString();

            if (att.Contains(','))
            {
                att = att.Split(',')[0];
            }

            switch (att)
            {
            case "Archive":
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Compressed":
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Device":
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Directory":
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Encrypted":
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "IntegrityStream":
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Hidden":
                Console.ForegroundColor = ConsoleColor.DarkMagenta;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Normal":
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "NoScrubData":
                Console.BackgroundColor = ConsoleColor.Gray;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "NotContentIndexed":
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Offline":
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "ReadOnly":
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "ReparsePoint":
                Console.BackgroundColor = ConsoleColor.DarkCyan;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "SparseFile":
                Console.BackgroundColor = ConsoleColor.DarkYellow;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "System":
                Console.BackgroundColor = ConsoleColor.DarkBlue;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            case "Temporary":
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.BackgroundColor = ConsoleColor.White;
                Console.Write(fn + addToEnd);
                Console.ResetColor();
                break;

            default:
                Console.Write(fn + addToEnd);
                break;
            }
        }