я создаю array list
и хочу напечатать содержимое массива в текстовом файле.
Программа берет значения из текстовых полей и сохраняет их в массиве с
добавить кнопку, я хочу сохранить его в текстовом файле в указанном месте ..
Я использую Microsoft Visual C # 2010 Express
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private ArrayList StoreItems;
public Form1()
{
this.StoreItems = new ArrayList();
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
}
//add button
private void button1_Click(object sender, EventArgs e)
{
// Make sure an item is complete before adding it to the inventory
if (this.textBox1.Text.Equals(""))
{
MessageBox.Show("You must enter a code");
this.textBox1.Focus();
return;
}
if (this.textBox2.Text.Equals(""))
{
MessageBox.Show("You must provide the name of the item");
this.textBox2.Focus();
return;
}
if (this.textBox3.Text.Equals(""))
{
MessageBox.Show("You must provide the name of the supplier");
this.textBox3.Focus();
return;
}
if (this.textBox4.Text.Equals(""))
{
MessageBox.Show("You must enter the price per unit");
this.textBox4.Focus();
return;
}
if (this.textBox5.Text.Equals(""))
{
MessageBox.Show("You must enter the number of the required products");
this.textBox5.Focus();
return;
}
if (this.textBox6.Text.Equals(""))
{
MessageBox.Show("You must enter the number of the current stock level");
this.textBox6.Focus();
return;
//string csl = this.textBox6.Text;
}
string inValue1, inValue2, inValue3, inValue4, inValue5, inValue6;
inValue1 = textBox1.Text;
inValue2 = textBox2.Text;
inValue3 = textBox3.Text;
inValue4 = textBox4.Text;
inValue5 = textBox5.Text;
inValue6 = textBox6.Text;
/* string result = (inValue1 + " " + inValue2 + " " + inValue3 + " "
+ inValue4 + " " + inValue5 + " " + inValue6); */
string result=(inValue1+inValue2+inValue3+inValue4+inValue5 +inValue6);
StoreItems.Add(result);
System.IO.File.AppendAllText(@"C:\Users\v\Desktop\text.txt", Environment.NewLine + result);
}
private void button2_Click(object sender, EventArgs e)
{
}