Hi All,
In my text file I have data like this:
[data]
123.txt
blabla
[Mobile]
345.txt
456.txt
[calls]
vsjs.txt
dsfs.txt
I would like to get these data (345.txt, 456.txt) and and the keyword to get is "[Mobile]".
I want to show 345.txt, 456.txt in rich textbox. If user makes any changes than I want to save it back. It means If user writes 345test.txt then the text file should be like this:
[data]
123.txt
blabla
[Mobile]
345test.txt
456.txt
[calls]
vsjs.txt
dsfs.txt
Advance thanks,
Darma
Loading
VulpesPosted Sep 9, 2014, 11:26 AM
using System.IO;
// ....
darma tejaPosted Sep 9, 2014, 2:52 PM
VulpesPosted Sep 9, 2014, 12:02 PM
private void button2_Click(object sender, EventArgs e)
{
if (richTextBox1.Text != originalText)
{
var allLines = lines.ToList();
allLines.RemoveRange(startIndex, originalCount);
allLines.InsertRange(startIndex, richTextBox1.Lines);
File.WriteAllLines(filePath, allLines);
lines = allLines.ToArray();
originalText = richTextBox1.Text;
originalCount = richTextBox1.Lines.Length;
}
}
I'd also disable button2 until button1 has been pressed.