Home > Net >  C # System. IO. File. How AppendAllText executed only once
C # System. IO. File. How AppendAllText executed only once

Time:03-24

Every time into the software execution time, always keep a number, how to execute only once, also can change to the original data cleaning off
 private void textBox1_TextChanged (object sender, EventArgs e) 
{
System. IO. File. AppendAllText (" C: \ \ Users \ \ Lamic \ \ Desktop \ \ data records. TXT ", textBox1. Text + "\ r \ n");
}

Private void MainInterface_Load (object sender, EventArgs e)
{
TextBox1. Text=System. IO. File. ReadAllText (" C: \ \ Users \ \ Lamic \ \ Desktop \ \ data records. TXT ");
}

CodePudding user response:

Into a System. IO. File. CreateText

CodePudding user response:

reference 1/f, big watermelon cut a piece of a kilo of reply:
change System. IO. File. CreateText good


reference 1/f, big watermelon cut a piece of a kilo of reply:
change System. IO. File. CreateText good


After changed, directly will throw an exception

CodePudding user response:

reference gezhu1212 reply: 3/f
Quote: refer to 1st floor big watermelon cut a piece of a kilo of reply:
change System. IO. File. CreateText good


reference 1/f, big watermelon cut a piece of a kilo of reply:
change System. IO. File. CreateText good


After changed, directly will throw an exception


 
Using (StreamWriter sw=File. CreateText (" test. TXT "))
{
Sw. WriteLine (" Hello ");
Sw. WriteLine (" World ");
}

CodePudding user response:

The
with ini or sqlite
At least you don't have to worry about, multithreading, abnormal electrical data abnormal problems such as

Useing moment said to regenerate the file as the one above, is 0 bytes come the next file

CodePudding user response:

Into a System. IO. File. WriteAllText
  •  Tags:  
  • C#
  • Related