Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ReadWrite
  4. {
  5.     class FileWriter
  6.     {
  7.         static void ReadWriteFile(string inFile, string outFile, string comparer)
  8.         {
  9.             string line;
  10.  
  11.             using (System.IO.StreamReader reader = new System.IO.StreamReader(inFile))
  12.             using (System.IO.StreamWriter writer = new System.IO.StreamWriter(outFile))
  13.             {
  14.                 while ((line = reader.ReadLine()) != null)
  15.                 {
  16.                     if (line.Contains(comparer))
  17.                     {
  18.                         writer.WriteLine(line);
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.  
  24.         static void Main(string[] args)
  25.         {
  26.             string inFile = args[0];
  27.             string outFile = args[1];
  28.             string comparer = args[2];
  29.             if (String.IsNullOrEmpty(inFile) || String.IsNullOrEmpty(outFile) || String.IsNullOrEmpty(comparer))
  30.                 throw new ArgumentException("Parametrii sunt incorecți");
  31.             ReadWriteFile(inFile, outFile, comparer);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement