Advertisement
Asinka

ReplaceSubstring-in-File

Jan 31st, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4.  
  5.  
  6. class ReplaceSubstringsInFile
  7. {
  8.     static void Main()
  9.     {
  10.         StreamReader inputFile = new StreamReader("../../Input.txt");
  11.         StreamWriter outputFile = new StreamWriter("../../Output.txt");
  12.  
  13.         using (inputFile)
  14.         {
  15.             using (outputFile)
  16.             {
  17.                 string fileContent = inputFile.ReadToEnd();
  18.                 inputFile.Close();
  19.  
  20.                 StringBuilder content = new StringBuilder(fileContent);
  21.                 content.Replace("start", "finish");
  22.  
  23.                 outputFile.WriteLine(content);
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement