2011-10-05 5 views
0

나는 이미 많은 문자열을 입력하고 그 행 뒤에 텍스트를 열려고합니다. 새 행을 만들고 정보를 in.all 정보로 쓰려고합니다. 내가 쓰고 싶은 새로운 라인에 대한 은 내가기존 텍스트의 새 행에 새 문자열 추가

//button open file 
private void button4_Click(object sender, EventArgs e) 
    { 
     if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) 
     { 

      label7.Text = openFileDialog1.FileName; 
      textBox7.Text = File.ReadAllText(label7.Text); 
     } 
    } 


    //button save file 
    private void button5_Click(object sender, EventArgs e) 
    { 
     if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) 
     { 

      File.WriteAllText(saveFileDialog1.FileName, textBox7.Text); 
     } 

    } 

     //this is the add button 
    private void button1_Click(object sender, EventArgs e) 
     { 

     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); 
     //File.WriteAllText("C:\\text.txt", textBox1.Text); 
     System.IO.File.WriteAllText(@"C:\Users\v\Desktop\text.txt", result); 
    } 

답변

4

아니에요 텍스트 상자에서을 완전히 분명 당신이 무슨 뜻인지,하지만 당신은 원하는 의심File.AppendAllText :

File.AppendAllText(filename, "new line of text"); 

또는 파일이 줄 바꿈으로 끝나지 않는 순간 :

File.AppendAllText(filename, Environment.NewLine + "new line of text");