Here is the code, there are three TextBoxes, values are entered into them, and Button1 saves the array in txt. In fact, the file is created, empty
public partial class Form1 : Form { public Form1() { InitializeComponent(); } public static string n1; public static string n2; public static string n3; public static string[] massiv = { n1, n2, n3 }; private void button1_Click(object sender, EventArgs e) { System.IO.File.WriteAllLines("C:\\Users\\D\\Documents\\Massiv.txt", massiv); } private void textBox1_TextChanged(object sender, EventArgs e) { n1 = textBox1.Text.ToString(); } private void textBox2_TextChanged(object sender, EventArgs e) { n2 = textBox2.Text.ToString(); } private void textBox4_TextChanged(object sender, EventArgs e) { n3 = textBox4.Text.ToString();
public static string[] massiv = { n1, n2, n3 };you added blank lines ...... whenTextChangeddoes not automatically replace values in the array, all you change is the values inn1,n2andn3- Aleksey Shimansky