Visual C#을 사용하여 텍스트 상자의 내용을 텍스트 파일로 저장하려고합니다. 나는 다음과 같은 코드를 사용Visual C# - 텍스트 상자의 내용을 .txt 파일로 작성
private void savelog_Click(object sender, EventArgs e)
{
if (folderBrowserDialog3save.ShowDialog() == DialogResult.OK)
{
// create a writer and open the file
TextWriter tw = new StreamWriter(folderBrowserDialog3save.SelectedPath + "logfile1.txt");
// write a line of text to the file
tw.WriteLine(logfiletextbox);
// close the stream
tw.Close();
MessageBox.Show("Saved to " + folderBrowserDialog3save.SelectedPath + "\\logfile.txt", "Saved Log File", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
하지만 난 단지 TEXTFILE에서 텍스트의 다음 줄 수 : 텍스트 상자에 실제로 있었는지의 짧은 부분에 의해 이어
System.Windows.Forms.TextBox, Text:
, '끝났다
을 ... '. 텍스트 상자의 전체 내용을 쓰지 않는 이유는 무엇입니까?
'filename' 매개 변수가 추가되었습니다. 좋은 점은, 나는 똑같은 것을 쓰려고했다. – MartinStettner
그래, 나는 왜 소수의 개발자들이'System.IO' 네임 스페이스가 존재한다는 것을 알고, 왜 그렇게 진주를 알지 못하는지 궁금하다. – Bobby
와우. 내 편이라. 감사! –