So you need to create first the file "mytext.txt" that contains the big text, and then you create the file "myresult.txt"! The two files must be near the executable file...
After that you create the project with the folowing 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 MyCodeProjectAnswer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string line = "";
string[] substr = new string[1000];
StreamReader reader = new StreamReader("mytext.txt");
StreamWriter writer = new StreamWriter("myresult.txt",true);
while (!reader.EndOfStream)
{
line = reader.ReadLine();
substr = line.Split(' ');
if (substr[0] == "clear")
writer.WriteLine(line);
}
reader.Close();
writer.Close();
}
}
}
Finally run it, and the output you want is in the "myresult.txt" file.
Regards,
KZ