Can be good for editing textfiles, all it does is find something and then replace it, for example you want to change names in a loong story, you insert the old name and then new name, and you're good to go!
This time I will include sourcecode.
Form.cs code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace QuicknEasy_TextEditor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OpenFileDialog browse = new OpenFileDialog();
private void button1_Click(object sender, EventArgs e)
{
browse.Title = "Select a file";
if (browse.ShowDialog() == DialogResult.Cancel)
return;
textBox3.Text = "Status: File selected.";
}
private void button2_Click(object sender, EventArgs e)
{
string Text = File.ReadAllText(browse.FileName);
if (Text.Contains(textBox1.Text))
{
Text = Text.Replace(textBox1.Text, textBox2.Text);
File.WriteAllText(browse.FileName, Text);
MessageBox.Show("Replacing text succeed!", "Success");
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "Status: No file selected";
textBox4.Text = " Find:";
textBox5.Text = " Replace:";
browse = new OpenFileDialog();
}
else
MessageBox.Show("Couldn't find the given text!", "Error");
}
}
}
Designer.cs code:
Code:
namespace QuicknEasy_TextEditor
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(144, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Browse file";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 95);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(144, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Replace with new text";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(53, 43);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(144, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(53, 69);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(144, 20);
this.textBox2.TabIndex = 3;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(12, 124);
this.textBox3.Name = "textBox3";
this.textBox3.ReadOnly = true;
this.textBox3.Size = new System.Drawing.Size(179, 20);
this.textBox3.TabIndex = 4;
this.textBox3.Text = "Status: No file selected.";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(-4, 43);
this.textBox4.Name = "textBox4";
this.textBox4.ReadOnly = true;
this.textBox4.Size = new System.Drawing.Size(57, 20);
this.textBox4.TabIndex = 5;
this.textBox4.Text = " Find:";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(-4, 69);
this.textBox5.Name = "textBox5";
this.textBox5.ReadOnly = true;
this.textBox5.Size = new System.Drawing.Size(57, 20);
this.textBox5.TabIndex = 6;
this.textBox5.Text = " Replace:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(208, 157);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "QuicknEasy TextEditor";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
}
}
Blah.






