Advertisement
Sephinroth

prac 9 ex 3 nooot final

Nov 29th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             FileStream tmp_file = new FileStream("e:/practice/tmp.txt", FileMode.Create, FileAccess.ReadWrite);
  14.             using(FileStream first_file = new FileStream("e:/practice/first.txt", FileMode.Open, FileAccess.Read))
  15.             {
  16.                 int i;
  17.                 while ((i = first_file.ReadByte()) != -1)
  18.                 tmp_file.WriteByte((byte)i);
  19.             }
  20.             using(FileStream first_file = new FileStream("e:/practice/first.txt", FileMode.Truncate, FileAccess.Write))
  21.             {
  22.                 using(FileStream second_file = new FileStream("e:/practice/second.txt", FileMode.Open, FileAccess.Read))
  23.                 {
  24.                 int i;
  25.                 while ((i = second_file.ReadByte()) != -1)
  26.                     first_file.WriteByte((byte)i);
  27.                 }
  28.             }
  29.             using(FileStream second_file = new FileStream("e:/practice/second.txt", FileMode.Truncate, FileAccess.Write))
  30.             {
  31.                 int i;
  32.                 while ((i = tmp_file.ReadByte()) != -1)
  33.                     second_file.WriteByte((byte)i);
  34.             }
  35.             tmp_file.Close();
  36.            
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement