Twój kod jest bardzo skomplikowany jak na to, co ma robić.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Test.wykonaj(textBox1, textBox2, textBox3);
}
private void test_Click(object sender, EventArgs e)
{
Test.wypisz(textBox1);
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void a_TextChanged(object sender, EventArgs e)
{
}
private void znacznik_CheckedChanged(object sender, EventArgs e)
{
}
}
class Test
{
public string a;
public string b;
public string c;
public static int z = 0;
public static string dodaj = "a";
public static string kod = "C:\\Nowyfolder\\foo.txt";
public static void wykonaj (TextBox textBox1, TextBox textBox2, TextBox textBox3)
{
Test[] test = new Test[10];
test[Test.z] = new Test();
test[Test.z].a = textBox1.Text;
test[Test.z].b = textBox2.Text;
test[Test.z].c = textBox3.Text;
if (znacznik.Checked)
{
if (!File.Exists("C:\\foo.txt"))
{
StreamWriter b = File.CreateText(Test.kod);
b.WriteLine(test[Test.z].a);
b.WriteLine(test[Test.z].b);
b.WriteLine(test[Test.z].c);
b.Close();
}
}
Test.z++;
Test.kod = "C:\\Nowyfolder\\" + Test.dodaj + "foo.txt";
Test.dodaj = Test.dodaj + "a";
}
public static void wypisz(TextBox textBox1)
{
Test.test[0].a = textBox1.Text;
}
}
}