private void Button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string buf = textBox1.Text; //buffer 1
string buf2 = textBox2.Text; //buffer 2
string fn = (textBox3.Text + ".txt"); //file name
File.AppendAllText(fn, "────────────────────────" + "\n\n" + buf + "\n" + buf2 + "\n\n"); //AppendAllText best choise for this // WriteAllText // Create
StreamReader sr = new StreamReader(fn);
//string text = (sr.ReadToEnd());
//listBox1.Items.Clear();
//listBox1.Items.Add(text);
string text;
while ((text = sr.ReadLine()) != null)
{
listBox1.Items.Add(text);
//string[] It = new string[10];
//for (int i = 0; i < It.Length; i++) listBox1.Items.Add((text + i).ToString());
//text += 10;
}
sr.Close();
listBox1.SelectedIndex = listBox1.Items.Count - 1;
File.WriteAllText("config.conf", fn);
}
private void button2_Click(object sender, EventArgs e)
{
//config initialisation
//File.Create("config.conf");
StreamReader lr = new StreamReader("config.conf");
string text = lr.ReadLine();
textBox3.AppendText(text);
lr.Close();
}
}
Как убрать .txt из переменной text в конце?