Butona tıklandığında txt dosyası yok ise oluşturmasını ve içini doldurmasını istiyorum. Çalıştırdığımda txt yi oluşturuyor fakat "System.IO.IOException: 'The process cannot access the file 'C:ayar.txt' because it is being used by another process.'" hatası veriyor ve içini doldurmuyor.
private void button13_Click(object sender, EventArgs e)
{
string dosya_yolu = @"C:ayar.txt";
if (File.Exists(dosya_yolu) == false)
{
File.Create(dosya_yolu);
TextWriter tt = new StreamWriter(dosya_yolu);
tt.Write("");
tt.Close();
StreamWriter st = File.AppendText(dosya_yolu);
st.WriteLine("Veritabanı_Adı");
st.WriteLine("Sql_Sunucu_Adı");
st.WriteLine("Sql_Kullanıcı_Adı");
st.WriteLine("Sql_Kullanıcı_Şifresi");
st.WriteLine("Firma_No (3 haneli)");
st.WriteLine("Dönem_No (2 haneli)");
st.Close();
}
panel1.Visible = true;
string[] lines = File.ReadAllLines(dosya_yolu);
textBox6.Text = lines[0];
textBox1.Text = lines[1];
textBox2.Text = lines[2];
textBox3.Text = lines[3];
textBox4.Text = lines[4];
textBox5.Text = lines[5];
}