Esempio n. 1
0
    public static void Main(String[] args)
    {
        // Проверка аргументов.
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : Indexer <filename>");
            return;
        }

        // Проверка существования файла
        if (!System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long          len  = file.Length;

        // Байты файла меняются местами, чтобы порядок их следования стал обратным.
        for (long i = 0; i < len / 2; ++i)
        {
            byte t;

            // Следует заметить, что при индексации переменной "file" вызывается
            // индексатор класса FileByteStream, который  считывает
            // и записывает байты в файл.
            t                 = file[i];
            file[i]           = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }
Esempio n. 2
0
    public static void Main(String[] args)
    {
        // Check for arguments.
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : Indexer <filename>");
            return;
        }

        // Check for file existence
        if (!System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long          len  = file.Length;

        // Swap bytes in the file to reverse it.
        for (long i = 0; i < len / 2; ++i)
        {
            byte t;

            // Note that indexing the "file" variable invokes the
            // indexer on the FileByteStream class, which reads
            // and writes the bytes in the file.
            t                 = file[i];
            file[i]           = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }
Esempio n. 3
0
    public static void Main(String[] args)
    {
        // 检查参数。
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : Indexer <filename>");
            return;
        }

        // 检查文件是否存在
        if (!System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long          len  = file.Length;

        // 交换文件中的字节以对其进行反转。
        for (long i = 0; i < len / 2; ++i)
        {
            byte t;

            // 请注意,为“file”变量建立索引会调用
            //  FileByteStream 类上的索引器,该索引器在文件中读取
            // 和写入字节。
            t                 = file[i];
            file[i]           = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }
Esempio n. 4
0
    public static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("syntax: indexer [filename]");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long          len  = file.Length;

        // Do the swap
        for (long i = 0; i < len / 2; i++)
        {
            byte t = file[i];
            file[i]           = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }
Esempio n. 5
0
    public static void Main(String[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("indexer <FileName>");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long          len  = file.Length;

        // Swap bytes in the file to reverse it.
        for (long i = 0; i < len / 2; i++)
        {
            byte t;

            t                 = file[i];
            file[i]           = file[len - i - 1];
            file[len - i - 1] = t;
        }
        file.Close();
    }
Esempio n. 6
0
    public static void Main(String[] args)
    {
        // 检查参数。
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : Indexer <filename>");
            return;
        }

        // 检查文件是否存在
        if (!System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long len = file.Length;

        // 交换文件中的字节以对其进行反转。
        for (long i = 0; i < len / 2; ++i)
        {
            byte t;

            // 请注意,为“file”变量建立索引会调用
            //  FileByteStream 类上的索引器,该索引器在文件中读取
            // 和写入字节。
            t = file[i];
            file[i] = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }
Esempio n. 7
0
    public static void Main(String[] args)
    {
        // Check for arguments.
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : Indexer <filename>");
            return;
        }

        // Check for file existence
        if (!System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return;
        }

        FileByteArray file = new FileByteArray(args[0]);
        long len = file.Length;

        // Swap bytes in the file to reverse it.
        for (long i = 0; i < len / 2; ++i)
        {
            byte t;

            // Note that indexing the "file" variable invokes the
            // indexer on the FileByteStream class, which reads
            // and writes the bytes in the file.
            t = file[i];
            file[i] = file[len - i - 1];
            file[len - i - 1] = t;
        }

        file.Close();
    }