Exemplo n.º 1
0
    static void CheckReader()
    {
        long kbyte = 1024;
        long mbyte = 1024 * kbyte;
        long gbyte = 1024 * mbyte;
        long size  = mbyte;

        Console.WriteLine("Запишем файлы при помощи разных потоков:\n" +
                          $"FileStream. Milliseconds:{MyFunctions.FileStreamSampleWrite("../../../FileStream.bin", size)}\n" +
                          $"BinaryStream. Milliseconds:{MyFunctions.BinaryStreamSampleWrite("../../../BinaryStream.bin", size)}\n" +
                          $"StreamWriter. Milliseconds:{MyFunctions.StreamWriterSampleWrite("../../../StreamWriter.bin", size)}\n" +
                          $"BufferedStream. Milliseconds:{MyFunctions.BufferedStreamSampleWrite("../../../BufferedStream.bin", size)}\n");

        Console.WriteLine("Прочтём файлы при помощи разных потоков:");
        byte[] bytesFromFileStream      = MyFunctions.FileStreamSampleRead("../../../FileStream.bin");
        int[]  integersFromBinatyStream = MyFunctions.BinaryStreamSampleRead("../../../BinaryStream.bin");
        string stringFromSreamReader    = MyFunctions.StreamReaderSample("../../../StreamWriter.bin");

        byte[] bytesFromBufferedStream = MyFunctions.BufferedStreamSampleRead("../../../BufferedStream.bin");
    }