Advertisement
Guest User

Untitled

a guest
Sep 25th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13.     public partial class Deneuralyzer : Form
  14.     {
  15.         public Deneuralyzer()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void Form1_Load(object sender, EventArgs e)
  21.         {
  22.  
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             using System;
  28.             using System.IO;
  29.             using System.Text.RegularExpressions;
  30.  
  31.  
  32.                     string filePath = @"C:\Program Files (x86)\location\to\application\textfile.txt";
  33.                     string searchText = "Count,2,";
  34.                     string replaceText = "Count,200,";
  35.                     ReplaceInFile(filePath, searchText, replaceText);
  36.  
  37.  
  38.                     static public void ReplaceInFile(string filePath, string searchText, string replaceText)
  39.                     {
  40.  
  41.                         StreamReader reader = new StreamReader(filePath);
  42.                         string content = reader.ReadToEnd();
  43.                         reader.Close();
  44.  
  45.                         content = Regex.Replace(content, searchText, replaceText);
  46.  
  47.                         StreamWriter writer = new StreamWriter(filePath);
  48.                         writer.Write(content);
  49.                         writer.Close();
  50.                     }
  51.  
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement