내가이 문제를 해결할 수 있는지 궁금합니다. 나는 그것에 두 권의 책이 저장된 DataGridView
을 가지고있다. 책을 클릭하면 책의 이야기가 RichTextBox
에로드됩니다. 해당 텍스트를 변경하고 저장하려면 .txt 파일에 내용을 저장하고 싶습니다. 어떻게해야할까요?.txt 형식의 파일 저장 (메모장)
나는 내가하고 싶은 것을보기 위해 코드를 포함시켰다.
string FileLine = "";
StreamWriter OutputFile;
foreach (Book book in myBookList)
{
//Book Book = new Book();
Book nBook = myBookList[dgv.CurrentCell.RowIndex];
//PROBLEM IS HERE
OutputFile = new StreamWriter(nBook.TxtFileName);
//-------------------------------------------------------------
//I want it to be something like this: {nBook.TxtFileName}.txt
//-------------------------------------------------------------
//Code to write data to file
OutputFile.WriteLine(FileLine);
OutputFile.Close();
}
감사 :
는 여기를 참조하십시오 : nBook.TxtFileName + "를 사용하지 않는 이유 http://stackoverflow.com/questions/7306214/append-lines-to-a-file-using-a-streamwriter –
이해할 수없는 TXT. " –
흠, 나는이 질문을 파일에 쓰는 방법을 묻는 것으로 해석했다. 끝에 파일 이름을".txt "로 가져 오는 것과 반대이다. @ JBTGE, 문제가 있습니까? –